mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
||||
fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||
self.get_attribute_by_name(name)
|
||||
self.GetAttributeNode(name)
|
||||
.map(|s| s.r().Value())
|
||||
}
|
||||
|
||||
|
@ -1158,9 +1158,21 @@ impl ElementMethods for Element {
|
|||
fn GetAttributeNS(&self,
|
||||
namespace: 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);
|
||||
self.get_attribute(namespace, &Atom::from_slice(&local_name))
|
||||
.map(|attr| attr.r().Value())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue