Re: [dom] Let DOMTokenList.prototype.add() return false if there are no supported tokens (#111)

@yoavweiss on IRC:
> the algorithm needs to be redefined so that in that case, the token is added to DOMTokenList, even if we returned false

Oops, I had overlooked this bit, that in the cases where `add()` returns false due to validation failure, the token actually isn't added. Why is that so? It's still not an invariant that all of the tokens in the list will be supported, since one can simply set the attribute directly, or have nonsense in the markup.

Since the "that is not in tokens" bit skips the validation steps, it's also the case that `list.add('foo')` would return true even if 'foo' is not a valid token, if that token is already in the list. Kind of non-obvious, I think.

What would you think about leaving the behavior with regard to updating the attribute exactly as it was, and having the return value only be affected by token validation?

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/111#issuecomment-158381138

Received on Friday, 20 November 2015 12:18:15 UTC