mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Fix mutation record when ReplaceChild handles DocumentFragment
This commit is contained in:
parent
b7e66c5349
commit
8b9162c49d
1 changed files with 18 additions and 8 deletions
|
@ -2001,6 +2001,21 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
let document = document_from_node(self).root();
|
let document = document_from_node(self).root();
|
||||||
Node::adopt(node, document.r());
|
Node::adopt(node, document.r());
|
||||||
|
|
||||||
|
// Step 12.
|
||||||
|
let mut nodes: Vec<JSRef<Node>> = vec!();
|
||||||
|
if node.type_id() == NodeTypeId::DocumentFragment {
|
||||||
|
// Collect fragment children before Step 11,
|
||||||
|
// because Node::insert removes a DocumentFragment's children,
|
||||||
|
// and we need them in Step 13.
|
||||||
|
// Issue filed against the spec:
|
||||||
|
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=28330
|
||||||
|
for child_node in node.children() {
|
||||||
|
nodes.push(child_node);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nodes.push(node);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Step 10.
|
// Step 10.
|
||||||
Node::remove(child, self, SuppressObserver::Suppressed);
|
Node::remove(child, self, SuppressObserver::Suppressed);
|
||||||
|
@ -2009,18 +2024,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
Node::insert(node, self, reference_child, SuppressObserver::Suppressed);
|
Node::insert(node, self, reference_child, SuppressObserver::Suppressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 12-14.
|
|
||||||
// Step 13: mutation records.
|
// Step 13: mutation records.
|
||||||
child.node_removed(self.is_in_doc());
|
child.node_removed(self.is_in_doc());
|
||||||
if node.type_id() == NodeTypeId::DocumentFragment {
|
for child_node in nodes {
|
||||||
for child_node in node.children() {
|
child_node.node_inserted();
|
||||||
child_node.node_inserted();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
node.node_inserted();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 15.
|
// Step 14.
|
||||||
Ok(Temporary::from_rooted(child))
|
Ok(Temporary::from_rooted(child))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue