mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
Implemented Node.adoptNode
Spec: http://dom.spec.whatwg.org/#dom-document-adoptnode
This commit is contained in:
parent
8a457a2caa
commit
990545c310
4 changed files with 19 additions and 1 deletions
|
@ -26,6 +26,7 @@ DOMInterfaces = {
|
|||
'Console': {},
|
||||
'Document': {
|
||||
'needsAbstract': [
|
||||
'adoptNode',
|
||||
'anchors',
|
||||
'applets',
|
||||
'body',
|
||||
|
|
|
@ -311,6 +311,21 @@ impl Document {
|
|||
Ok(Node::clone(node, Some(abstract_self), clone_children))
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-document-adoptnode
|
||||
pub fn AdoptNode(&self, abstract_self: &JS<Document>, node: &JS<Node>) -> Fallible<JS<Node>> {
|
||||
// Step 1.
|
||||
if node.is_document() {
|
||||
return Err(NotSupported);
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
let mut adoptee = node.clone();
|
||||
Node::adopt(&mut adoptee, abstract_self);
|
||||
|
||||
// Step 3.
|
||||
Ok(adoptee)
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-document-createevent
|
||||
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<JS<Event>> {
|
||||
match interface.as_slice() {
|
||||
|
|
|
@ -1016,7 +1016,7 @@ impl Node {
|
|||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#concept-node-adopt
|
||||
fn adopt(node: &mut JS<Node>, document: &JS<Document>) {
|
||||
pub fn adopt(node: &mut JS<Node>, document: &JS<Document>) {
|
||||
// Step 1.
|
||||
match node.parent_node() {
|
||||
Some(ref mut parent) => Node::remove(node, parent, Unsuppressed),
|
||||
|
|
|
@ -38,6 +38,8 @@ interface Document : Node {
|
|||
|
||||
[Throws]
|
||||
Node importNode(Node node, optional boolean deep = false);
|
||||
[Throws]
|
||||
Node adoptNode(Node node);
|
||||
|
||||
[Creator, Throws]
|
||||
Event createEvent(DOMString interface_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue