Skip to content

Commit

Permalink
Auto merge of #9064 - nox:them-attr-names, r=Manishearth
Browse files Browse the repository at this point in the history
Implement Element.getAttributeNames

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9064)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Feb 26, 2016
2 parents aaad24c + b8ae589 commit 9186819
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions components/script/dom/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,11 @@ impl ElementMethods for Element {
self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self))
}

// https://dom.spec.whatwg.org/#dom-element-getattributenames
fn GetAttributeNames(&self) -> Vec<DOMString> {
self.attrs.borrow().iter().map(|attr| attr.Name()).collect()
}

// https://dom.spec.whatwg.org/#dom-element-getattribute
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
self.GetAttributeNode(name)
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/webidls/Element.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface Element : Node {
[SameObject]
readonly attribute NamedNodeMap attributes;
[Pure]
sequence<DOMString> getAttributeNames();
[Pure]
DOMString? getAttribute(DOMString name);
[Pure]
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
Expand Down
6 changes: 3 additions & 3 deletions tests/wpt/metadata/dom/interfaces.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@
[Element interface: element must inherit property "hasAttributes" with the proper type (7)]
expected: FAIL

[Element interface: element must inherit property "removeAttributeNode" with the proper type (21)]
[Element interface: element must inherit property "removeAttributeNode" with the proper type (22)]
expected: FAIL

[Element interface: calling removeAttributeNode(Attr) on element with too few arguments must throw TypeError]
expected: FAIL

[Element interface: element must inherit property "query" with the proper type (33)]
[Element interface: element must inherit property "query" with the proper type (34)]
expected: FAIL

[Element interface: calling query(DOMString) on element with too few arguments must throw TypeError]
expected: FAIL

[Element interface: element must inherit property "queryAll" with the proper type (34)]
[Element interface: element must inherit property "queryAll" with the proper type (35)]
expected: FAIL

[Element interface: calling queryAll(DOMString) on element with too few arguments must throw TypeError]
Expand Down
3 changes: 0 additions & 3 deletions tests/wpt/metadata/dom/nodes/attributes.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
[Basic functionality of removeAttributeNode]
expected: FAIL

[getAttributeNames tests]
expected: FAIL

[Own property names should only include all-lowercase qualified names for an HTML element in an HTML document]
expected: FAIL

6 changes: 3 additions & 3 deletions tests/wpt/metadata/html/dom/interfaces.html.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1986,19 +1986,19 @@
[Element interface: document.createElement("noscript") must inherit property "hasAttributes" with the proper type (7)]
expected: FAIL
[Element interface: document.createElement("noscript") must inherit property "removeAttributeNode" with the proper type (21)]
[Element interface: document.createElement("noscript") must inherit property "removeAttributeNode" with the proper type (22)]
expected: FAIL
[Element interface: calling removeAttributeNode(Attr) on document.createElement("noscript") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("noscript") must inherit property "query" with the proper type (33)]
[Element interface: document.createElement("noscript") must inherit property "query" with the proper type (34)]
expected: FAIL
[Element interface: calling query(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("noscript") must inherit property "queryAll" with the proper type (34)]
[Element interface: document.createElement("noscript") must inherit property "queryAll" with the proper type (35)]
expected: FAIL
[Element interface: calling queryAll(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
Expand Down
1 change: 1 addition & 0 deletions tests/wpt/web-platform-tests/dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ <h1>DOM IDL tests</h1>

boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString name);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
void setAttribute(DOMString name, DOMString value);
Expand Down
2 changes: 1 addition & 1 deletion tests/wpt/web-platform-tests/dom/nodes/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@

function getEnumerableOwnProps2(obj) {
return Object.getOwnPropertyNames(obj).filter(
(name) => Object.getOwnPropertyDescriptor(obj, name).enumerable)
function (name) { return Object.getOwnPropertyDescriptor(obj, name).enumerable; })
}

test(function() {
Expand Down
1 change: 1 addition & 0 deletions tests/wpt/web-platform-tests/html/dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ <h1>HTML IDL tests</h1>

boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString name);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
void setAttribute(DOMString name, DOMString value);
Expand Down

0 comments on commit 9186819

Please sign in to comment.