Handle the XPath / (root) operator correctly for nodes that aren't attached to the...
authorcevans@google.com <cevans@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 01:28:54 +0000 (01:28 +0000)
committercevans@google.com <cevans@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Aug 2012 01:28:54 +0000 (01:28 +0000)
commit6c516c9caabfe3c0e1295125975ac8453be4a964
tree3bb9b84e576cc30172f87aef21018d7fcdf06cb5
parente9e2b919aca4506a4c2cfe25552f5dc27e11ad66
Handle the XPath / (root) operator correctly for nodes that aren't attached to the document.
https://bugs.webkit.org/show_bug.cgi?id=36427

Reviewed by Abhishek Arya.

Source/WebCore:

We now behave the same as Firefox 14.
The consensus seems to be that the XPath spec is ambiguous for the case of detached nodes, and that using the fragment root is more intuitive than the document root for the case of detached nodes.
For example, http://www.w3.org/TR/xpath/ section 2 "Location Paths" is only clear for attached nodes: "A / by itself selects the root node of the document containing the context node. If it is followed by a relative location path, then the location path selects the set of nodes that would be selected by the relative location path relative to the root node of the document containing the context node."

Test: fast/xpath/xpath-detached-nodes.html

* xml/XPathPath.cpp:
(WebCore::XPath::LocationPath::evaluate): Jump to the root of the detached subtree instead of the parent document if the node isn't attached to the document.

LayoutTests:

* fast/xpath/xpath-detached-nodes-expected.txt: Added.
* fast/xpath/xpath-detached-nodes.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/xpath/xpath-detached-nodes-expected.txt [new file with mode: 0644]
LayoutTests/fast/xpath/xpath-detached-nodes.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/xml/XPathPath.cpp