Is it possible to override the HTMLElement.classList property in WebKit (Chrome) ?
I am trying with the following code:
Object.defineProperty(window.HTMLElement.prototype, "classList", {
get : function() {
console.log("test");
return 1;
},
set : function(newValue){ },
enumerable : true,
configurable : true}
);
However, calling classList of a DIV would still return the DOMTokenList.
I guess you should do what you’ve done with
HTMLDivElement, notHTMLElement. However, I did that and still no result.But if you want to do your job for the moment, you can apply your code directly on the
divinstance itself:and:
See this fiddle.