Implement Element::hasAttributes

This commit is contained in:
Nazım Can Altınova 2016-04-22 15:18:08 +03:00
parent 6f801e3f3f
commit 47f43d45a7
6 changed files with 55 additions and 9 deletions

View file

@ -1335,6 +1335,11 @@ impl ElementMethods for Element {
self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self))
}
// https://dom.spec.whatwg.org/#dom-element-hasattributes
fn HasAttributes(&self) -> bool {
!self.attrs.borrow().is_empty()
}
// https://dom.spec.whatwg.org/#dom-element-getattributenames
fn GetAttributeNames(&self) -> Vec<DOMString> {
self.attrs.borrow().iter().map(|attr| attr.Name()).collect()

View file

@ -35,6 +35,8 @@ interface Element : Node {
[Pure]
sequence<DOMString> getAttributeNames();
[Pure]
boolean hasAttributes();
[Pure]
DOMString? getAttribute(DOMString name);
[Pure]
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);