aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/attr.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index 6923c32c0ef..0c8e92f7d42 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -38,12 +38,13 @@ pub enum AttrValue {
impl AttrValue {
pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
- let mut atoms: Vec<Atom> = vec!();
- for token in split_html_space_chars(&tokens).map(Atom::from_slice) {
- if !atoms.iter().any(|atom| *atom == token) {
- atoms.push(token);
- }
- }
+ let atoms =
+ split_html_space_chars(&tokens)
+ .map(Atom::from_slice)
+ .fold(vec![], |mut acc, atom| {
+ if !acc.contains(&atom) { acc.push(atom) }
+ acc
+ });
AttrValue::TokenList(tokens, atoms)
}