Re: [whatwg/dom] Spec for DOMTokenList stringifier disagrees with every single implementation (#105)

To be clear, the only thing we're discussing here is something like

```
data:text/html,<!doctype html>
<div class="a a"></div>
<script>document.body.textContent = document.body.firstChild.classList</script>
```

which is "a a" per current spec, Chrome, Firefox, and Edge.  The old spec said to return just "a".

The current spec still says that when you call a method that mutates the list, it gets reserialized with whitespace collapsed and duplicates removed.  Nobody has explicitly objected to keeping this that I know of, although nobody (except I guess WebKit) implements this either.  See the first couple of comments in this thread, and #201.  Example test-case for this:

```
data:text/html,<!doctype html>
<div class="a a"></div>
<script>
document.body.firstChild.classList.add("b");
document.body.textContent = document.body.firstChild.classList;
</script>
```

which should be "a b" per spec but in non-WebKit browsers is "a a b".

@cdumez, to clarify, are you also not okay with dropping just the bit that was changed back in the spec (when no mutation methods are called)?  It's not obvious to me why it's more useful to authors to return "a" instead of "a a" in the test case I give here, since they have all the methods they need to deal with the logical contents of the list.  Why do authors need direct access to a string with duplicates removed and whitespace normalized?  If they do, per the current spec they can normalize the content attribute by doing something like .replace("a", "a") or .remove("nonexistent-token") (although non-WebKit UAs don't support this currently).

@bzbarsky, you only mentioned .classList stringification in your report here.  Do you also have a problem with the serialization steps being run on all the mutation methods, which non-WebKit browsers also interoperably don't do?  Or is that different for some reason?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/105#issuecomment-242109781

Received on Wednesday, 24 August 2016 15:55:31 UTC