Skip to content

Commit

Permalink
Added Element::get_tokenlist_attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Dec 26, 2014
1 parent 8859286 commit 51fac3d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/script/dom/element.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 51fac3d

Please sign in to comment.