mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #9064 - nox:them-attr-names, r=Manishearth
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 -->
This commit is contained in:
commit
918681931f
8 changed files with 16 additions and 10 deletions
|
@ -1228,6 +1228,11 @@ impl ElementMethods for Element {
|
||||||
self.attr_list.or_init(|| NamedNodeMap::new(&window_from_node(self), self))
|
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
|
// https://dom.spec.whatwg.org/#dom-element-getattribute
|
||||||
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||||
self.GetAttributeNode(name)
|
self.GetAttributeNode(name)
|
||||||
|
|
|
@ -34,6 +34,8 @@ interface Element : Node {
|
||||||
[SameObject]
|
[SameObject]
|
||||||
readonly attribute NamedNodeMap attributes;
|
readonly attribute NamedNodeMap attributes;
|
||||||
[Pure]
|
[Pure]
|
||||||
|
sequence<DOMString> getAttributeNames();
|
||||||
|
[Pure]
|
||||||
DOMString? getAttribute(DOMString name);
|
DOMString? getAttribute(DOMString name);
|
||||||
[Pure]
|
[Pure]
|
||||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
|
|
|
@ -120,19 +120,19 @@
|
||||||
[Element interface: element must inherit property "hasAttributes" with the proper type (7)]
|
[Element interface: element must inherit property "hasAttributes" with the proper type (7)]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling removeAttributeNode(Attr) on element with too few arguments must throw TypeError]
|
[Element interface: calling removeAttributeNode(Attr) on element with too few arguments must throw TypeError]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling query(DOMString) on element with too few arguments must throw TypeError]
|
[Element interface: calling query(DOMString) on element with too few arguments must throw TypeError]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling queryAll(DOMString) on element with too few arguments must throw TypeError]
|
[Element interface: calling queryAll(DOMString) on element with too few arguments must throw TypeError]
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
[Basic functionality of removeAttributeNode]
|
[Basic functionality of removeAttributeNode]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[getAttributeNames tests]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Own property names should only include all-lowercase qualified names for an HTML element in an HTML document]
|
[Own property names should only include all-lowercase qualified names for an HTML element in an HTML document]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1986,19 +1986,19 @@
|
||||||
[Element interface: document.createElement("noscript") must inherit property "hasAttributes" with the proper type (7)]
|
[Element interface: document.createElement("noscript") must inherit property "hasAttributes" with the proper type (7)]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling removeAttributeNode(Attr) on document.createElement("noscript") with too few arguments must throw TypeError]
|
[Element interface: calling removeAttributeNode(Attr) on document.createElement("noscript") with too few arguments must throw TypeError]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling query(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
[Element interface: calling query(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
||||||
expected: FAIL
|
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
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: calling queryAll(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
[Element interface: calling queryAll(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
||||||
|
|
|
@ -287,6 +287,7 @@ interface Element : Node {
|
||||||
|
|
||||||
boolean hasAttributes();
|
boolean hasAttributes();
|
||||||
[SameObject] readonly attribute NamedNodeMap attributes;
|
[SameObject] readonly attribute NamedNodeMap attributes;
|
||||||
|
sequence<DOMString> getAttributeNames();
|
||||||
DOMString? getAttribute(DOMString name);
|
DOMString? getAttribute(DOMString name);
|
||||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
void setAttribute(DOMString name, DOMString value);
|
void setAttribute(DOMString name, DOMString value);
|
||||||
|
|
|
@ -585,7 +585,7 @@ function getEnumerableOwnProps1(obj) {
|
||||||
|
|
||||||
function getEnumerableOwnProps2(obj) {
|
function getEnumerableOwnProps2(obj) {
|
||||||
return Object.getOwnPropertyNames(obj).filter(
|
return Object.getOwnPropertyNames(obj).filter(
|
||||||
(name) => Object.getOwnPropertyDescriptor(obj, name).enumerable)
|
function (name) { return Object.getOwnPropertyDescriptor(obj, name).enumerable; })
|
||||||
}
|
}
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
|
|
|
@ -289,6 +289,7 @@ interface Element : Node {
|
||||||
|
|
||||||
boolean hasAttributes();
|
boolean hasAttributes();
|
||||||
[SameObject] readonly attribute NamedNodeMap attributes;
|
[SameObject] readonly attribute NamedNodeMap attributes;
|
||||||
|
sequence<DOMString> getAttributeNames();
|
||||||
DOMString? getAttribute(DOMString name);
|
DOMString? getAttribute(DOMString name);
|
||||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
void setAttribute(DOMString name, DOMString value);
|
void setAttribute(DOMString name, DOMString value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue