Avoid duplicated tokens in AttrValue::from_serialized_tokenlist

This commit is contained in:
Bruno de Oliveira Abinader 2014-12-16 11:02:04 -04:00
parent eb3678fa28
commit c5f7e553e4
2 changed files with 6 additions and 8 deletions

View file

@ -38,8 +38,12 @@ pub enum AttrValue {
impl AttrValue { impl AttrValue {
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue { pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
let atoms = split_html_space_chars(tokens.as_slice()) let mut atoms: Vec<Atom> = vec!();
.map(|token| Atom::from_slice(token)).collect(); 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) AttrValue::TokenList(tokens, atoms)
} }

View file

@ -3,9 +3,6 @@
[CSS .foo selectors must not match elements without any class] [CSS .foo selectors must not match elements without any class]
expected: FAIL 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] [empty classList should return the empty string since the ordered set parser skip the whitespaces]
expected: FAIL expected: FAIL
@ -63,9 +60,6 @@
[classList.remove must not break case-sensitive CSS selector matching] [classList.remove must not break case-sensitive CSS selector matching]
expected: FAIL expected: FAIL
[classList.remove must remove duplicated tokens]
expected: FAIL
[classList.remove must collapse whitespace around removed tokens] [classList.remove must collapse whitespace around removed tokens]
expected: FAIL expected: FAIL