diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-02-29 00:19:18 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-02-29 00:19:18 +0100 |
commit | c0d79062b5bb34ee3c28e7c591c2b22d361830b9 (patch) | |
tree | efbdeeb4ad497185012739112b5f6ea498af849f | |
parent | be6940db59a2e8bf4fac45911848edbc8cd3dd8d (diff) | |
download | servo-c0d79062b5bb34ee3c28e7c591c2b22d361830b9.tar.gz servo-c0d79062b5bb34ee3c28e7c591c2b22d361830b9.zip |
Fix step 14.2 of Range::ExtractContents
We need the last inclusive ancestor of start node that is not an inclusive ancestor
of end node, not the first that is an inclusive ancestor of it.
-rw-r--r-- | components/script/dom/range.rs | 5 | ||||
-rw-r--r-- | tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini | 17 |
2 files changed, 3 insertions, 19 deletions
diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 88fc9ad35bc..c6efae90b98 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -564,8 +564,9 @@ impl RangeMethods for Range { } else { // Step 14.1-2. let reference_node = start_node.ancestors() - .find(|n| n.is_inclusive_ancestor_of(end_node.r())) - .unwrap(); + .take_while(|n| !n.is_inclusive_ancestor_of(&end_node)) + .last() + .unwrap_or(Root::from_ref(&start_node)); // Step 14.3. (reference_node.GetParentNode().unwrap(), reference_node.index() + 1) }; diff --git a/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini b/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini deleted file mode 100644 index e509efc61c4..00000000000 --- a/tests/wpt/metadata/dom/ranges/Range-extractContents.html.ini +++ /dev/null @@ -1,17 +0,0 @@ -[Range-extractContents.html] - type: testharness - [Resulting cursor position for range 18 [paras[0\].firstChild, 0, paras[1\].firstChild, 0\]] - expected: FAIL - - [Resulting cursor position for range 19 [paras[0\].firstChild, 0, paras[1\].firstChild, 8\]] - expected: FAIL - - [Resulting cursor position for range 20 [paras[0\].firstChild, 3, paras[3\], 1\]] - expected: FAIL - - [Resulting cursor position for range 50 [paras[2\].firstChild, 4, comment, 2\]] - expected: FAIL - - [Resulting cursor position for range 51 [paras[3\], 1, comment, 8\]] - expected: FAIL - |