- From: Isiah Meadows <notifications@github.com>
- Date: Wed, 05 Aug 2020 01:31:14 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/884@github.com>
It's pretty blatantly very similar, and `setlike` objects have almost the same functionality. - Setlikes use the native ES `Set` under the hood, which carries the same semantics as `DOMTokenList`s with regards to iteration order. - `domTokenList.add(...items)` almost perfectly aligns with the native `setlike.add(item)`. The only difference is the return value (`undefined` instead of `this`) and the fact `domTokenList.add(...items)` accepts a list of tokens. - `domTokenList.remove(...items)` similarly aligns with `setlike.delete(item)`, just in addition to the above, it goes by a different name. - `domTokenList.contains(item)` is different from `setlike.has(item)` literally in name and identity only. - `domTokenList.length` is different from `setlike.size` literally in name and getter identity only. - For iterators, `DOMTokenList`s return indices for their keys, while setlikes delegate to the ES spec, which returns the values as the keys as well. For `values` and `@@iterator`, it's equivalent in practice. There is one major caveat: this may require spec changes either to WebIDL, the DOM, or both to migrate `add`. Not a simple change and might just be a pipe dream, but I feel it's definitely something worth exploring. -- 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/884
Received on Wednesday, 5 August 2020 08:31:28 UTC