Implemented Document.importNode

Spec:
http://dom.spec.whatwg.org/#dom-document-importnode
This commit is contained in:
Bruno de Oliveira Abinader 2014-03-17 00:55:57 -04:00
parent f34a64049a
commit 8a457a2caa
4 changed files with 24 additions and 3 deletions

View file

@ -28,6 +28,7 @@ use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement;
use dom::mouseevent::MouseEvent;
use dom::node::{Node, ElementNodeTypeId, DocumentNodeTypeId, NodeHelpers, INode};
use dom::node::{CloneChildren, DoNotCloneChildren};
use dom::text::Text;
use dom::processinginstruction::ProcessingInstruction;
use dom::uievent::UIEvent;
@ -294,6 +295,22 @@ impl Document {
Ok(ProcessingInstruction::new(target, data, abstract_self))
}
// http://dom.spec.whatwg.org/#dom-document-importnode
pub fn ImportNode(&self, abstract_self: &JS<Document>, node: &JS<Node>, deep: bool) -> Fallible<JS<Node>> {
// Step 1.
if node.is_document() {
return Err(NotSupported);
}
// Step 2.
let clone_children = match deep {
true => CloneChildren,
false => DoNotCloneChildren
};
Ok(Node::clone(node, Some(abstract_self), clone_children))
}
// http://dom.spec.whatwg.org/#dom-document-createevent
pub fn CreateEvent(&self, interface: DOMString) -> Fallible<JS<Event>> {
match interface.as_slice() {