Monkey patching constructors in builtin class hierarchies?

Oriol _ oriol-bugzilla at hotmail.com
Tue Oct 24 17:14:52 UTC 2017


The problem is that DOM defines the [`Element` interface](https://dom.spec.whatwg.org/#element) without a [\[Constructor\] extended attribute](https://heycam.github.io/webidl/#Constructor).


This means that `Element` can't be directly constructed. However, you can still use something like

```js
class FooBar extends Element {
  constructor() {
    console.log("patched in Element");
    let el = document.createElement('foo-bar');
    return Object.setPrototypeOf(el, FooBar.prototype);
  }
}
```


-Oriol

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171024/3c77212a/attachment.html>


More information about the es-discuss mailing list