Proposal for asTokenList(attr)

  1. Set won’t allow by-index access to tokens
  2. DOMTokenList uses ascii-whitespace as the delimiter, \s includes much more

I’ve iterated on @briankardell’s initial code and published tokenlist. This was done to fully implement the specified interface, provide tests and expose a simple constructor.

The implementation sports callbacks to encode and decode tokens, thereby allowing us to provide an interface that accepts and resolves Elements for simpler interactions with ID Reference Lists such as aria-labelledby and aria-describedby. This idea is exposed as Element.prototype._referenceListFor(attributeName). That said, I’m not sure additional operations such as .prepend() are required in this domain.

I’m unclear on what DOMTokenList.from() should really do, but tinkering around should be easy enough.

1 Like