Implement Document::CreateAttributeNS()

This commit is contained in:
Anthony Ramine 2015-04-08 02:00:18 +02:00
parent 7b4f6126c8
commit 2353bc4798
4 changed files with 17 additions and 18 deletions

View file

@ -997,6 +997,18 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
Ok(Attr::new(window.r(), name, value, l_name, ns!(""), None, None))
}
// http://dom.spec.whatwg.org/#dom-document-createattributens
fn CreateAttributeNS(self, namespace: Option<DOMString>, qualified_name: DOMString)
-> Fallible<Temporary<Attr>> {
let (namespace, prefix, local_name) =
try!(validate_and_extract(namespace, &qualified_name));
let window = self.window.root();
let value = AttrValue::String("".to_owned());
let qualified_name = Atom::from_slice(&qualified_name);
Ok(Attr::new(window.r(), local_name, value, qualified_name,
namespace, prefix, None))
}
// http://dom.spec.whatwg.org/#dom-document-createdocumentfragment
fn CreateDocumentFragment(self) -> Temporary<DocumentFragment> {
DocumentFragment::new(self)

View file

@ -40,14 +40,16 @@ interface Document : Node {
[NewObject, Throws]
ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
[NewObject, Throws]
Attr createAttribute(DOMString localName);
[NewObject, Throws]
Node importNode(Node node, optional boolean deep = false);
[Throws]
Node adoptNode(Node node);
[NewObject, Throws]
Attr createAttribute(DOMString localName);
[NewObject, Throws]
Attr createAttributeNS(DOMString? namespace, DOMString localName);
[NewObject, Throws]
Event createEvent(DOMString interface_);