Re: [w3c/webcomponents] Returning a Proxy from a Custom Element constructor (#857)

<!--
At a higher level I bet this is simply architecture design that people aren't willing to modify (though they probably can if they tried). The question to that is, if it can be done with backwards compatibility, then why not?

I don't think that adding Proxy support (and changing underlying architecture) would break backwards compatibility in this case.

Obviously we could totally change the "type" of an object by using a Proxy wrapper, but then we'd find out very quickly that shooting ourselves in the foot is not going to get us anywhere.
-->

> the “why” part of this

Would you mind summarizing some bullet points?

----

This totally works:

```js
class MyEl extends HTMLElement {
  constructor() {
    super();
    Object.setPrototypeOf(
      this,
      new Proxy(Object.create(HTMLElement.prototype), {
        get(...args) {
          console.log("Muahaha.");
          return undefined;
        },
        set(...args) {
          console.log("Muahaha.");
          return true;
        }
      })
    );
  }
}

customElements.define("my-el3", MyEl);
const el = new MyEl();
document.body.appendChild(el);
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/857#issuecomment-560012716

Received on Saturday, 30 November 2019 19:08:30 UTC