w3ctag / polyfills

Finding on polyfills
https://w3ctag.github.io/polyfills
18 stars 6 forks source link

Library example #3

Closed triblondon closed 7 years ago

triblondon commented 7 years ago

@domenic suggests this part would benefit from a further example:

Instead, use the speculative polyfill as a library

Brian:

Is domenic asking for something as simple as this?

DO

element._asTokenList('attrName').add("foo")

DON'T

Element.prototype.tokenList = Element.prototype.tokenList || Element.prototype._asTokenList;

element.asTokenList('attrName').add("foo")

(I suggested asTokenList as a way to act on any attribute as a DOMTokenList https://briankardell.wordpress.com/2016/03/29/tokenlists-missing-web-dna/)

triblondon commented 7 years ago

Proposed solution is in PR: https://github.com/w3ctag/polyfills/issues/19. Will take feedback there.