Implement SetNamedItem, SetNamedItemNS, SetAttributeNode and SetAttributeNodeNS

This commit is contained in:
Mathieu Hordesseaux 2015-12-23 17:21:45 +01:00
parent bc44ae679f
commit 322b120f8a
11 changed files with 105 additions and 67 deletions

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::error::{Error, Fallible};
@ -58,6 +59,16 @@ impl NamedNodeMapMethods for NamedNodeMap {
self.owner.get_attribute(&ns, &Atom::from(&*local_name))
}
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem
fn SetNamedItem(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
self.owner.SetAttributeNode(attr)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditemns
fn SetNamedItemNS(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
self.SetNamedItem(attr)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
fn RemoveNamedItem(&self, name: DOMString) -> Fallible<Root<Attr>> {
let name = self.owner.parsed_name(name);