Auto merge of #11589 - GuillaumeGomez:contains, r=nox

Make DOMTokenList.contains not throw anymore

Fixes #11579.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11589)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-04 08:34:05 -05:00
commit ec869eff19
5 changed files with 9 additions and 70 deletions

View file

@ -70,15 +70,14 @@ impl DOMTokenListMethods for DOMTokenList {
}
// https://dom.spec.whatwg.org/#dom-domtokenlist-contains
fn Contains(&self, token: DOMString) -> Fallible<bool> {
self.check_token_exceptions(&token).map(|token| {
self.attribute().map_or(false, |attr| {
let attr = attr.r();
attr.value()
.as_tokens()
.iter()
.any(|atom: &Atom| *atom == token)
})
fn Contains(&self, token: DOMString) -> bool {
let token = Atom::from(token);
self.attribute().map_or(false, |attr| {
let attr = attr.r();
attr.value()
.as_tokens()
.iter()
.any(|atom: &Atom| *atom == token)
})
}

View file

@ -9,7 +9,7 @@ interface DOMTokenList {
[Pure]
getter DOMString? item(unsigned long index);
[Pure, Throws]
[Pure]
boolean contains(DOMString token);
[Throws]
void add(DOMString... tokens);