Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid duplicated tokens in AttrValue::from_serialized_tokenlist
  • Loading branch information
brunoabinader committed Dec 26, 2014
1 parent eb3678f commit c5f7e55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 6 additions & 2 deletions components/script/dom/attr.rs
Expand Up @@ -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<Atom> = 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)
}

Expand Down
6 changes: 0 additions & 6 deletions tests/wpt/metadata/dom/nodes/Element-classlist.html.ini
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c5f7e55

Please sign in to comment.