aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/attr.rs8
-rw-r--r--components/script/dom/domtokenlist.rs8
2 files changed, 4 insertions, 12 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index a8f4b897f15..782ab3fd884 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -14,7 +14,7 @@ use dom::window::Window;
use dom::virtualmethods::vtable_for;
use devtools_traits::AttrInfo;
-use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars};
+use util::str::{DOMString, parse_unsigned_integer, split_html_space_chars, str_join};
use string_cache::{Atom, Namespace};
@@ -49,11 +49,7 @@ impl AttrValue {
}
pub fn from_atomic_tokens(atoms: Vec<Atom>) -> AttrValue {
- let tokens = atoms.iter().fold(String::new(), |mut s, atom| {
- if !s.is_empty() { s.push('\x20'); }
- s.push_str(atom);
- s
- });
+ let tokens = str_join(&atoms, "\x20");
AttrValue::TokenList(tokens, atoms)
}
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs
index f863996e9ca..f7a02cdf572 100644
--- a/components/script/dom/domtokenlist.rs
+++ b/components/script/dom/domtokenlist.rs
@@ -13,7 +13,7 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::element::{Element, AttributeHandlers};
use dom::node::window_from_node;
-use util::str::{DOMString, HTML_SPACE_CHARACTERS};
+use util::str::{DOMString, HTML_SPACE_CHARACTERS, str_join};
use string_cache::Atom;
use std::borrow::ToOwned;
@@ -158,10 +158,6 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
// https://dom.spec.whatwg.org/#stringification-behavior
fn Stringifier(self) -> DOMString {
let tokenlist = self.element.root().r().get_tokenlist_attribute(&self.local_name);
- tokenlist.iter().fold(String::new(), |mut s, atom| {
- if !s.is_empty() { s.push('\x20'); }
- s.push_str(atom);
- s
- })
+ str_join(&tokenlist, "\x20")
}
}