Skip to content
Permalink
Browse files

Added Element::get_tokenlist_attribute

  • Loading branch information
brunoabinader committed Dec 26, 2014
1 parent 8859286 commit 51fac3d2cc69c6d4c47ed4ad3f0ee2b1248f8b30
Showing with 10 additions and 0 deletions.
  1. +10 −0 components/script/dom/element.rs
@@ -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));

0 comments on commit 51fac3d

Please sign in to comment.
You can’t perform that action at this time.