mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #10762 - canaltinova:has_attributes, r=nox
Implement Element::hasAttributes Fixes #10748 . Implement Element::hasAttributes. I'm not sure if tests are enough. I'm open to suggestion :) <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10762) <!-- Reviewable:end -->
This commit is contained in:
commit
8163347e34
6 changed files with 55 additions and 9 deletions
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue