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
This commit is contained in:
Corey Farwell 2015-07-04 18:44:29 -07:00
parent 9b2ba3d713
commit 91b0671e1d
3 changed files with 6 additions and 9 deletions

View file

@ -157,6 +157,11 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
// https://dom.spec.whatwg.org/#stringification-behavior // https://dom.spec.whatwg.org/#stringification-behavior
fn Stringifier(self) -> DOMString { 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
})
} }
} }

View file

@ -1,5 +0,0 @@
[DOMTokenList-stringifier.html]
type: testharness
[DOMTokenList stringifier]
expected: FAIL

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
[empty classList should return the empty string since the ordered set parser skip the whitespaces]
expected: FAIL
[computed style must update when setting .className] [computed style must update when setting .className]
expected: FAIL expected: FAIL