From e7a9f44df941ef41809ab833fdb5d2b07b8be823 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 13 Dec 2015 20:21:12 +0100 Subject: [PATCH] Fix DOMStringMap's stringifier behaviour according to the spec It should just return its associated attribute's value, if any. https://github.com/whatwg/dom/issues/105 --- components/script/dom/domtokenlist.rs | 7 +++---- .../dom/lists/DOMTokenList-stringifier.html | 16 +++++++++------- .../dom/nodes/Element-classlist.html | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 6c1c931c407..dd7eb17ba74 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -12,7 +12,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::element::Element; use dom::node::window_from_node; use string_cache::Atom; -use util::str::{DOMString, HTML_SPACE_CHARACTERS, str_join}; +use util::str::{DOMString, HTML_SPACE_CHARACTERS}; #[dom_struct] pub struct DOMTokenList { @@ -129,10 +129,9 @@ impl DOMTokenListMethods for DOMTokenList { } } - // https://dom.spec.whatwg.org/#stringification-behavior + // https://dom.spec.whatwg.org/#concept-dtl-serialize fn Stringifier(&self) -> DOMString { - let tokenlist = self.element.get_tokenlist_attribute(&self.local_name); - DOMString::from(str_join(&tokenlist, "\x20")) + self.element.get_string_attribute(&self.local_name) } // check-tidy: no specs after this line diff --git a/tests/wpt/web-platform-tests/dom/lists/DOMTokenList-stringifier.html b/tests/wpt/web-platform-tests/dom/lists/DOMTokenList-stringifier.html index d5ff1612593..b125388e02b 100644 --- a/tests/wpt/web-platform-tests/dom/lists/DOMTokenList-stringifier.html +++ b/tests/wpt/web-platform-tests/dom/lists/DOMTokenList-stringifier.html @@ -6,18 +6,20 @@
- + diff --git a/tests/wpt/web-platform-tests/dom/nodes/Element-classlist.html b/tests/wpt/web-platform-tests/dom/nodes/Element-classlist.html index e8ef26fcdb5..8c870305049 100644 --- a/tests/wpt/web-platform-tests/dom/nodes/Element-classlist.html +++ b/tests/wpt/web-platform-tests/dom/nodes/Element-classlist.html @@ -62,9 +62,9 @@ test(function () { assert_equals( elem.className, ' ' ); }, 'className should contain initial markup whitespace'); test(function () { - assert_equals( elem.classList + '', '', 'implicit' ); - assert_equals( elem.classList.toString(), '', 'explicit' ); -}, 'empty classList should return the empty string since the ordered set parser skip the whitespaces'); + assert_equals( elem.classList + '', ' ', 'implicit' ); + assert_equals( elem.classList.toString(), ' ', 'explicit' ); +}, 'classList should contain initial markup whitespace'); test(function () { assert_throws( 'SYNTAX_ERR', function () { elem.classList.contains(''); } ); }, '.contains(empty_string) must throw a SYNTAX_ERR');