The short of this is that I want HTMLElement.prototype.myList
to function like HTMLElement.prototype.classList
or .dataset
I can't figure out how to instantiate a DOMTokenList
, however. I can get code to work against a polyfill (https://github.com/jwilsson/domtokenlist/blob/master/src/DOMTokenList.js), but not the native object. Against native, everything I try gives me: Uncaught TypeError: Illegal invocation
var n = new DOMTokenList(); // illegal
new DOMTokenList({}, 'foo'); // illegal
or via prototypes, I get more illegal / not function errors.
So does anyone know how to use the native code to do this?