Implementing getAttributeNode() and similar methods.

This commit is contained in:
KALPESH KRISHNA 2015-10-19 00:05:49 +05:30
parent b847e4dd77
commit 3971b8ce27
4 changed files with 18 additions and 32 deletions

View file

@ -1150,7 +1150,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-getattribute
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
self.get_attribute_by_name(name)
self.GetAttributeNode(name)
.map(|s| s.r().Value())
}
@ -1158,9 +1158,21 @@ impl ElementMethods for Element {
fn GetAttributeNS(&self,
namespace: Option<DOMString>,
local_name: DOMString) -> Option<DOMString> {
self.GetAttributeNodeNS(namespace, local_name)
.map(|attr| attr.r().Value())
}
// https://dom.spec.whatwg.org/#dom-element-getattributenode
fn GetAttributeNode(&self, name: DOMString) -> Option<Root<Attr>> {
self.get_attribute_by_name(name)
}
// https://dom.spec.whatwg.org/#dom-element-getattributenodens
fn GetAttributeNodeNS(&self,
namespace: Option<DOMString>,
local_name: DOMString) -> Option<Root<Attr>> {
let namespace = &namespace_from_domstring(namespace);
self.get_attribute(namespace, &Atom::from_slice(&local_name))
.map(|attr| attr.r().Value())
}
// https://dom.spec.whatwg.org/#dom-element-setattribute