Re: [whatwg/dom] Web reality: DOMTokenList's toggle() cannot always update the corresponding attribute (#451)

Then we want to spec that if you replace a value that's not in the token set, it doesn't update, but if you replace a value in the token set with itself, it does update.

I'm a bit sad that if we change this back there will be no simple and foolproof way to update the attribute without changing its values.  You'd have to do something like

```javascript
if (list.length) {
  list.add(list[0]);
} else {
  list = "";
}
```
or
```javascript
list.remove("i-hope-this-value-isnt-ever-actually-in-the-list");
```
Or just update the values twice, like
```javascript
list.toggle("a");
list.toggle("a");
```
If `replace()` did update the value unconditionally, you could do simply `replace("a", "a")`.

But I guess it's not worth going against existing implementations.

-- 
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/451#issuecomment-320645518

Received on Monday, 7 August 2017 12:04:31 UTC