mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Panic if DOMTokenList#contains is called for an unparsed attribute.
Previously, if the attribute was not parsed into a token list, and the tokens() method returned None, DOMTokenList#contains would silently return false. This issue was encountered in <https://github.com/servo/servo/pull/4076> and took quite some time to figure out.
This commit is contained in:
parent
6e19955129
commit
449aaec5c2
1 changed files with 5 additions and 2 deletions
|
@ -90,10 +90,13 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
// http://dom.spec.whatwg.org/#dom-domtokenlist-contains
|
||||
fn Contains(self, token: DOMString) -> Fallible<bool> {
|
||||
self.check_token_exceptions(token.as_slice()).map(|slice| {
|
||||
self.attribute().root().and_then(|attr| attr.value().tokens().map(|tokens| {
|
||||
self.attribute().root().map(|attr| {
|
||||
let value = attr.value();
|
||||
let tokens = value.tokens()
|
||||
.expect("Should have parsed this attribute");
|
||||
let atom = Atom::from_slice(slice);
|
||||
tokens.iter().any(|token| *token == atom)
|
||||
})).unwrap_or(false)
|
||||
}).unwrap_or(false)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue