Bug 9035

Summary: document.evaluate and createNSResolver miss on namespaced elements
Product: WebKit Reporter: Paul Everitt <paul>
Component: DOMAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Minor CC: cdumez
Priority: P2 Keywords: HasReduction
Version: 420+   
Hardware: Mac (PowerPC)   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 10489, 7788    
Attachments:
Description Flags
createNSResolver test case
none
Patch darin: review+

Description Paul Everitt 2006-05-22 02:23:28 PDT
I am using the nightly builds to gain JS access to XPath selection of nodes.  In the test case I create an XHTML2 using a string in JS and calling the DOMParser.  To match on namespaced elements, I create a resolver with xmldoc.createNSResolver and pass it into the xmldoc.evaluate call.

Unfortunately the XPath selection matches nothing in WebKit.  It works in Firefox.
Comment 1 Paul Everitt 2006-05-22 02:25:13 PDT
Created attachment 8457 [details]
createNSResolver test case

A test case with HTML and JS that works in Firefox but fails in the WebKit nightly from May 20 2006.
Comment 2 Anders Carlsson 2006-06-03 10:08:05 PDT
Created attachment 8680 [details]
Patch
Comment 3 Darin Adler 2006-06-03 12:47:54 PDT
Comment on attachment 8680 [details]
Patch

-Step::Step(AxisType axis, const String& nodeTest, const Vector<Predicate*>& predicates)
+Step::Step(AxisType axis, const String& nodeTest, const Vector<Predicate*> &predicates)

The above is not a good change.

+    Parser *parser = Parser::current();

We put the * next to the type.

+    if (!parser->m_currentNamespaceURI.isNull()) {
+        m_namespaceURI = parser->m_currentNamespaceURI;
+        parser->m_currentNamespaceURI = String();
+    }

Why the if here? Seems that check should be omitted.

+            $$ = new String($1->deprecatedString().mid(colon + 1));

This could use String::substring and then you would not need to bother with the conversion to/from DeprecatedString.

r=me
Comment 4 Darin Adler 2006-06-03 18:58:43 PDT
I got an idea:

-    if (m_nodeSetPosition + 1 >= m_nodeSet.size())
+    if (m_nodeSetPosition + 1 > m_nodeSet.size())

This could also be fixed by removing the +1 and keeping the =.
Comment 5 Paul Everitt 2006-06-04 11:19:16 PDT
I just tried the test case in the most recent nightly and it now passes.  Thanks Anders!
Comment 6 Lucas Forschler 2019-02-06 09:02:33 PST
Mass moving XML DOM bugs to the "DOM" Component.