mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Implement adopting steps
https://dom.spec.whatwg.org/#concept-node-adopt https://github.com/whatwg/dom/pull/66
This commit is contained in:
parent
3f9b6f8586
commit
e2b8febfd5
2 changed files with 17 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -98,7 +98,14 @@ pub trait VirtualMethods {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://dom.spec.whatwg.org/#concept-node-clone (step 5)
|
||||
/// https://dom.spec.whatwg.org/#concept-node-adopt-ext
|
||||
fn adopting_steps(&self, old_doc: &Document) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.adopting_steps(old_doc);
|
||||
}
|
||||
}
|
||||
|
||||
/// https://dom.spec.whatwg.org/#concept-node-clone-ext
|
||||
fn cloning_steps(&self, copy: &Node, maybe_doc: Option<&Document>,
|
||||
clone_children: CloneChildrenFlag) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue