diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 2b8213718191..a848ca85e0c8 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -38,8 +38,12 @@ pub enum AttrValue { impl AttrValue { pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue { - let atoms = split_html_space_chars(tokens.as_slice()) - .map(|token| Atom::from_slice(token)).collect(); + let mut atoms: Vec = vec!(); + for token in split_html_space_chars(tokens.as_slice()).map(|slice| Atom::from_slice(slice)) { + if !atoms.iter().any(|atom| *atom == token) { + atoms.push(token); + } + } AttrValue::TokenList(tokens, atoms) } diff --git a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini index c072735d5026..3ec7b9070e15 100644 --- a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini +++ b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini @@ -3,9 +3,6 @@ [CSS .foo selectors must not match elements without any class] expected: FAIL - [classList must be correct for an element that has classes] - expected: FAIL - [empty classList should return the empty string since the ordered set parser skip the whitespaces] expected: FAIL @@ -63,9 +60,6 @@ [classList.remove must not break case-sensitive CSS selector matching] expected: FAIL - [classList.remove must remove duplicated tokens] - expected: FAIL - [classList.remove must collapse whitespace around removed tokens] expected: FAIL