mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #6507 - Ms2ger:node-insert, r=Manishearth
Fix a bug in Node::pre_insert.
It was accidentally broken in 3ce368fa28
.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6507)
<!-- Reviewable:end -->
This commit is contained in:
commit
6f25ecea3f
5 changed files with 7745 additions and 7 deletions
|
@ -1626,11 +1626,14 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7-8.
|
// Step 7-8.
|
||||||
|
let reference_child_root;
|
||||||
let reference_child = match child {
|
let reference_child = match child {
|
||||||
Some(child) if child == node => node.GetNextSibling(),
|
Some(child) if child == node => {
|
||||||
_ => None
|
reference_child_root = node.GetNextSibling();
|
||||||
|
reference_child_root.r()
|
||||||
|
},
|
||||||
|
_ => child
|
||||||
};
|
};
|
||||||
let reference_child = reference_child.r().or(child);
|
|
||||||
|
|
||||||
// Step 9.
|
// Step 9.
|
||||||
let document = document_from_node(parent);
|
let document = document_from_node(parent);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -298,9 +298,9 @@ test(function() {
|
||||||
a.appendChild(b);
|
a.appendChild(b);
|
||||||
a.appendChild(c);
|
a.appendChild(c);
|
||||||
assert_array_equals(a.childNodes, [b, c]);
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
assert_equals(a.replaceChild(b, b), b);
|
assert_equals(a.insertBefore(b, b), b);
|
||||||
assert_array_equals(a.childNodes, [b, c]);
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
assert_equals(a.replaceChild(c, c), c);
|
assert_equals(a.insertBefore(c, c), c);
|
||||||
assert_array_equals(a.childNodes, [b, c]);
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
}, "Inserting a node before itself should not move the node");
|
}, "Inserting a node before itself should not move the node");
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -265,6 +265,18 @@ test(function() {
|
||||||
assert_equals(a.replaceChild(d, c), c);
|
assert_equals(a.replaceChild(d, c), c);
|
||||||
assert_array_equals(a.childNodes, [b, d, e]);
|
assert_array_equals(a.childNodes, [b, d, e]);
|
||||||
}, "Replacing a node with its next sibling should work (4 children)");
|
}, "Replacing a node with its next sibling should work (4 children)");
|
||||||
|
test(function() {
|
||||||
|
var a = document.createElement("div");
|
||||||
|
var b = document.createElement("div");
|
||||||
|
var c = document.createElement("div");
|
||||||
|
a.appendChild(b);
|
||||||
|
a.appendChild(c);
|
||||||
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
|
assert_equals(a.replaceChild(b, b), b);
|
||||||
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
|
assert_equals(a.replaceChild(c, c), c);
|
||||||
|
assert_array_equals(a.childNodes, [b, c]);
|
||||||
|
}, "Replacing a node with itself should not move the node");
|
||||||
|
|
||||||
// Step 7.
|
// Step 7.
|
||||||
test(function() {
|
test(function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue