aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--components/script/dom/domtokenlist.rs7
-rw-r--r--tests/wpt/metadata/dom/lists/DOMTokenList-stringifier.html.ini5
-rw-r--r--tests/wpt/metadata/dom/nodes/Element-classlist.html.ini3
3 files changed, 6 insertions, 9 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
+ })
}
}
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