aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-09-03 01:01:39 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2015-09-08 09:32:49 +0200
commite2b8febfd523ad26a72be27b85c3fc2ff89ea088 (patch)
tree1e4b924dfb36f9f1ca48b1e550704816786b9883 /components/script/dom/node.rs
parent3f9b6f8586b60929ccbfe1cf51b84887ef711b77 (diff)
downloadservo-e2b8febfd523ad26a72be27b85c3fc2ff89ea088.tar.gz
servo-e2b8febfd523ad26a72be27b85c3fc2ff89ea088.zip
Implement adopting steps
https://dom.spec.whatwg.org/#concept-node-adopt https://github.com/whatwg/dom/pull/66
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs23
1 files changed, 9 insertions, 14 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index f46cbc0be11..b0c8d79228e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -1415,24 +1415,19 @@ impl Node {
// https://dom.spec.whatwg.org/#concept-node-adopt
pub fn adopt(node: &Node, document: &Document) {
// Step 1.
- let parent_node = node.GetParentNode();
- match parent_node {
- Some(ref parent) => {
- Node::remove(node, parent, SuppressObserver::Unsuppressed);
- }
- None => (),
- }
-
+ let old_doc = node.owner_doc();
// Step 2.
- let node_doc = document_from_node(node);
- if node_doc.r() != document {
+ node.remove_self();
+ if &*old_doc != document {
+ // Step 3.
for descendant in node.traverse_preorder() {
- descendant.r().set_owner_doc(document);
+ descendant.set_owner_doc(document);
+ }
+ // Step 4.
+ for descendant in node.traverse_preorder() {
+ vtable_for(&descendant).adopting_steps(&old_doc);
}
}
-
- // Step 3.
- // If node is an element, it is _affected by a base URL change_.
}
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity