Skip to content
Permalink
Browse files

Avoid duplicated tokens in AttrValue::from_serialized_tokenlist

  • Loading branch information
brunoabinader committed Dec 26, 2014
1 parent eb3678f commit c5f7e553e43d865194d3251e584b166f4aa1095d
Showing with 6 additions and 8 deletions.
  1. +6 −2 components/script/dom/attr.rs
  2. +0 −6 tests/wpt/metadata/dom/nodes/Element-classlist.html.ini
@@ -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)
}

@@ -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

0 comments on commit c5f7e55

Please sign in to comment.
You can’t perform that action at this time.