mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Implement DOMTokenList.add
This commit is contained in:
parent
08e7cf24cd
commit
aa29dc195d
2 changed files with 16 additions and 1 deletions
|
@ -100,4 +100,18 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
}).unwrap_or(false)
|
||||
})
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-add
|
||||
fn Add(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()));
|
||||
if !atoms.iter().any(|atom| *atom == token) {
|
||||
atoms.push(token);
|
||||
}
|
||||
}
|
||||
element.set_atomic_tokenlist_attribute(&self.local_name, atoms);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,9 @@ interface DOMTokenList {
|
|||
|
||||
[Throws]
|
||||
boolean contains(DOMString token);
|
||||
[Throws]
|
||||
void add(DOMString... tokens);
|
||||
|
||||
//void add(DOMString... tokens);
|
||||
//void remove(DOMString... tokens);
|
||||
//boolean toggle(DOMString token, optional boolean force);
|
||||
//stringifier;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue