Skip to content

Commit 85f2bf8

Browse files
committed
1 parent 5478c7c commit 85f2bf8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

components/script/dom/node.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,24 +1415,17 @@ impl Node {
14151415
// https://dom.spec.whatwg.org/#concept-node-adopt
14161416
pub fn adopt(node: &Node, document: &Document) {
14171417
// Step 1.
1418-
let parent_node = node.GetParentNode();
1419-
match parent_node {
1420-
Some(ref parent) => {
1421-
Node::remove(node, parent, SuppressObserver::Unsuppressed);
1422-
}
1423-
None => (),
1424-
}
1425-
1418+
let old_doc = node.owner_doc();
14261419
// Step 2.
1427-
let node_doc = document_from_node(node);
1428-
if node_doc.r() != document {
1420+
node.remove_self();
1421+
if &*old_doc != document {
14291422
for descendant in node.traverse_preorder() {
1430-
descendant.r().set_owner_doc(document);
1423+
// Step 3.
1424+
descendant.set_owner_doc(document);
1425+
// Step 4.
1426+
vtable_for(&descendant).adopting_steps(&old_doc);
14311427
}
14321428
}
1433-
1434-
// Step 3.
1435-
// If node is an element, it is _affected by a base URL change_.
14361429
}
14371430

14381431
// https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity

components/script/dom/virtualmethods.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ pub trait VirtualMethods {
113113
}
114114
}
115115

116-
/// https://dom.spec.whatwg.org/#concept-node-clone (step 5)
116+
/// https://dom.spec.whatwg.org/#concept-node-adopt-ext
117+
fn adopting_steps(&self, old_doc: &Document) {
118+
if let Some(ref s) = self.super_type() {
119+
s.adopting_steps(old_doc);
120+
}
121+
}
122+
123+
/// https://dom.spec.whatwg.org/#concept-node-clone-ext
117124
fn cloning_steps(&self, copy: &Node, maybe_doc: Option<&Document>,
118125
clone_children: CloneChildrenFlag) {
119126
if let Some(ref s) = self.super_type() {

0 commit comments

Comments
 (0)