Skip to content
Permalink
Browse files

Implement DOMTokenList.remove

  • Loading branch information
brunoabinader committed Dec 26, 2014
1 parent aa29dc1 commit 2cfb4648ceea2da3865d619cd4a480bf69901e5f
Showing with 16 additions and 1 deletion.
  1. +14 −0 components/script/dom/domtokenlist.rs
  2. +2 −1 components/script/dom/webidls/DOMTokenList.webidl
@@ -114,4 +114,18 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
element.set_atomic_tokenlist_attribute(&self.local_name, atoms);
Ok(())
}

// https://dom.spec.whatwg.org/#dom-domtokenlist-remove
fn Remove(self, tokens: Vec<DOMString>) -> ErrorResult {
let element = self.element.root();
let mut atoms = element.get_tokenlist_attribute(&self.local_name);
for token in tokens.iter() {
let token = try!(self.check_token_exceptions(token.as_slice()));
atoms.iter().position(|atom| *atom == token).and_then(|index| {
atoms.remove(index)
});
}
element.set_atomic_tokenlist_attribute(&self.local_name, atoms);
Ok(())
}
}
@@ -12,8 +12,9 @@ interface DOMTokenList {
boolean contains(DOMString token);
[Throws]
void add(DOMString... tokens);
[Throws]
void remove(DOMString... tokens);

//void remove(DOMString... tokens);
//boolean toggle(DOMString token, optional boolean force);
//stringifier;
};

0 comments on commit 2cfb464

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