aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/attr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/attr.rs')
-rw-r--r--components/script/dom/attr.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index d1b288bd7ad..014fa5f5357 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -37,9 +37,21 @@ pub enum AttrValue {
}
impl AttrValue {
- pub fn from_tokenlist(tokens: DOMString) -> AttrValue {
- let atoms = split_html_space_chars(tokens.as_slice())
- .map(|token| Atom::from_slice(token)).collect();
+ pub fn from_serialized_tokenlist(tokens: DOMString) -> AttrValue {
+ 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)
+ }
+
+ pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
+ let tokens = {
+ let slices: Vec<&str> = atoms.iter().map(|atom| atom.as_slice()).collect();
+ slices.connect("\x20")
+ };
AttrValue::TokenList(tokens, atoms)
}