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': {},
|
'Console': {},
|
||||||
'Document': {
|
'Document': {
|
||||||
'needsAbstract': [
|
'needsAbstract': [
|
||||||
|
'adoptNode',
|
||||||
'anchors',
|
'anchors',
|
||||||
'applets',
|
'applets',
|
||||||
'body',
|
'body',
|
||||||
|
|
|
@ -311,6 +311,21 @@ impl Document {
|
||||||
Ok(Node::clone(node, Some(abstract_self), clone_children))
|
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
|
// http://dom.spec.whatwg.org/#dom-document-createevent
|
||||||
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<JS<Event>> {
|
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<JS<Event>> {
|
||||||
match interface.as_slice() {
|
match interface.as_slice() {
|
||||||
|
|
|
@ -1016,7 +1016,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#concept-node-adopt
|
// 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.
|
// Step 1.
|
||||||
match node.parent_node() {
|
match node.parent_node() {
|
||||||
Some(ref mut parent) => Node::remove(node, parent, Unsuppressed),
|
Some(ref mut parent) => Node::remove(node, parent, Unsuppressed),
|
||||||
|
|
|
@ -38,6 +38,8 @@ interface Document : Node {
|
||||||
|
|
||||||
[Throws]
|
[Throws]
|
||||||
Node importNode(Node node, optional boolean deep = false);
|
Node importNode(Node node, optional boolean deep = false);
|
||||||
|
[Throws]
|
||||||
|
Node adoptNode(Node node);
|
||||||
|
|
||||||
[Creator, Throws]
|
[Creator, Throws]
|
||||||
Event createEvent(DOMString interface_);
|
Event createEvent(DOMString interface_);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue