mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Implementing getAttributeNode() and similar methods.
This commit is contained in:
parent
b847e4dd77
commit
3971b8ce27
4 changed files with 18 additions and 32 deletions
|
@ -1150,7 +1150,7 @@ impl ElementMethods for Element {
|
||||||
|
|
||||||
// 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.get_attribute_by_name(name)
|
self.GetAttributeNode(name)
|
||||||
.map(|s| s.r().Value())
|
.map(|s| s.r().Value())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1158,9 +1158,21 @@ impl ElementMethods for Element {
|
||||||
fn GetAttributeNS(&self,
|
fn GetAttributeNS(&self,
|
||||||
namespace: Option<DOMString>,
|
namespace: Option<DOMString>,
|
||||||
local_name: DOMString) -> 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);
|
let namespace = &namespace_from_domstring(namespace);
|
||||||
self.get_attribute(namespace, &Atom::from_slice(&local_name))
|
self.get_attribute(namespace, &Atom::from_slice(&local_name))
|
||||||
.map(|attr| attr.r().Value())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
||||||
|
|
|
@ -37,6 +37,10 @@ interface Element : Node {
|
||||||
DOMString? getAttribute(DOMString name);
|
DOMString? getAttribute(DOMString name);
|
||||||
[Pure]
|
[Pure]
|
||||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||||
|
[Pure]
|
||||||
|
Attr? getAttributeNode(DOMString name);
|
||||||
|
[Pure]
|
||||||
|
Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
|
||||||
[Throws]
|
[Throws]
|
||||||
void setAttribute(DOMString name, DOMString value);
|
void setAttribute(DOMString name, DOMString value);
|
||||||
[Throws]
|
[Throws]
|
||||||
|
|
|
@ -150,12 +150,6 @@
|
||||||
[Element interface: operation hasAttributes()]
|
[Element interface: operation hasAttributes()]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[Element interface: operation getAttributeNode(DOMString)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: operation getAttributeNodeNS(DOMString,DOMString)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: operation setAttributeNode(Attr)]
|
[Element interface: operation setAttributeNode(Attr)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -174,18 +168,6 @@
|
||||||
[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 "getAttributeNode" with the proper type (17)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: calling getAttributeNode(DOMString) on element with too few arguments must throw TypeError]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: element must inherit property "getAttributeNodeNS" with the proper type (18)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: calling getAttributeNodeNS(DOMString,DOMString) on element with too few arguments must throw TypeError]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: element must inherit property "setAttributeNode" with the proper type (19)]
|
[Element interface: element must inherit property "setAttributeNode" with the proper type (19)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -2064,18 +2064,6 @@
|
||||||
[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 "getAttributeNode" with the proper type (17)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: calling getAttributeNode(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: document.createElement("noscript") must inherit property "getAttributeNodeNS" with the proper type (18)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: calling getAttributeNodeNS(DOMString,DOMString) on document.createElement("noscript") with too few arguments must throw TypeError]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Element interface: document.createElement("noscript") must inherit property "setAttributeNode" with the proper type (19)]
|
[Element interface: document.createElement("noscript") must inherit property "setAttributeNode" with the proper type (19)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue