aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2015-07-04 18:44:29 -0700
committerCorey Farwell <coreyf@rwell.org>2015-07-08 04:42:50 +0900
commit91b0671e1d7b27b1b41c7b34597353386f3fbde6 (patch)
tree458851ed39a6d087b8cef848cf70831a89296ed2 /components/script/dom
parent9b2ba3d7134b4ec33c5a57e69faf48408d44ee74 (diff)
downloadservo-91b0671e1d7b27b1b41c7b34597353386f3fbde6.tar.gz
servo-91b0671e1d7b27b1b41c7b34597353386f3fbde6.zip
Join tokens when stringifying DOMTokenList
Previous, it would return the original String straight from the AttrValue, which might contain extraaneous whitespace. The spec specifies to just join the tokens together with \x20 https://dom.spec.whatwg.org/#stringification-behavior
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/domtokenlist.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs
index b3656ae4b7c..f863996e9ca 100644
--- a/components/script/dom/domtokenlist.rs
+++ b/components/script/dom/domtokenlist.rs
@@ -157,6 +157,11 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
// https://dom.spec.whatwg.org/#stringification-behavior
fn Stringifier(self) -> DOMString {
- self.element.root().r().get_string_attribute(&self.local_name)
+ 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
+ })
}
}