From 91b0671e1d7b27b1b41c7b34597353386f3fbde6 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 4 Jul 2015 18:44:29 -0700 Subject: [PATCH] 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 --- components/script/dom/domtokenlist.rs | 7 ++++++- .../metadata/dom/lists/DOMTokenList-stringifier.html.ini | 5 ----- tests/wpt/metadata/dom/nodes/Element-classlist.html.ini | 3 --- 3 files changed, 6 insertions(+), 9 deletions(-) delete mode 100644 tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini 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 + }) } } diff --git a/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini b/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini deleted file mode 100644 index fa87a8bd09b..00000000000 --- a/tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[DOMTokenList-stringifier.html] - type: testharness - [DOMTokenList stringifier] - expected: FAIL - diff --git a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini index 2526f96f80b..de405c47bc8 100644 --- a/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini +++ b/tests/wpt/metadata/dom/nodes/Element-classlist.html.ini @@ -3,9 +3,6 @@ [CSS .foo selectors must not match elements without any class] 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] expected: FAIL