For functions on prototypes I used to do something like:
var attachShadow = HTMLElement.prototype.attachShadow
HTMLElement.prototype.attachShadow = function (option) {
var sh = attachShadow.call(this, option)
console.log('ShadowDOM Attached!')
return sh
}
On this example, I modified the attachShadow
method inside the HTMLElement
prototype to get me notified when a new shadowDOM
get attached to an element.
Now I wanna do something similar with ShadowRoot.prototype.adoptedStyleSheets
, but this time adoptedStyleSheets
is a getter/setter, var adoptedStyleSheets = HTMLElement.prototype.adoptedStyleSheets
will cause an error: Uncaught TypeError: Illegal invocation
.
I'm not sure what to do, How to modify getters/setters on prototypes?