mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Added Element::get_tokenlist_attribute
This commit is contained in:
parent
8859286a99
commit
51fac3d2cc
1 changed files with 10 additions and 0 deletions
|
@ -655,6 +655,7 @@ pub trait AttributeHandlers {
|
|||
fn set_url_attribute(self, name: &Atom, value: DOMString);
|
||||
fn get_string_attribute(self, name: &Atom) -> DOMString;
|
||||
fn set_string_attribute(self, name: &Atom, value: DOMString);
|
||||
fn get_tokenlist_attribute(self, name: &Atom) -> Vec<Atom>;
|
||||
fn set_tokenlist_attribute(self, name: &Atom, value: DOMString);
|
||||
fn set_atomic_tokenlist_attribute(self, name: &Atom, tokens: Vec<Atom>);
|
||||
fn get_uint_attribute(self, name: &Atom) -> u32;
|
||||
|
@ -847,6 +848,15 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
self.set_attribute(name, AttrValue::String(value));
|
||||
}
|
||||
|
||||
fn get_tokenlist_attribute(self, name: &Atom) -> Vec<Atom> {
|
||||
self.get_attribute(ns!(""), name).root().map(|attr| {
|
||||
attr.value()
|
||||
.tokens()
|
||||
.expect("Expected a TokenListAttrValue")
|
||||
.to_vec()
|
||||
}).unwrap_or(vec!())
|
||||
}
|
||||
|
||||
fn set_tokenlist_attribute(self, name: &Atom, value: DOMString) {
|
||||
assert!(name.as_slice() == name.as_slice().to_ascii_lower().as_slice());
|
||||
self.set_attribute(name, AttrValue::from_serialized_tokenlist(value));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue