RE: Callback when an event handler has been added to a custom element

From: Mitar [] 

> Hm, but message port API itself has such a side-effect:

I think that is just a very bad API. The platform is unfortunately full of bad APIs :). In particular, a difference between two different ways of adding event listeners is not something authors ever think about.

But regardless, if that's all you want, you could do it easily by declaring your custom element class like so:

class MyCustomElement {
  set onmessage(handler) {
    this.addEventListener("message", handler);
  // ...

> For me this feels like leaking internal implementation details to the outside.

I strongly disagree. I would instead say it feels like getting rid of magical implicit I/O behavior, in favor of making the code say what it does and do what it says.

Received on Saturday, 7 November 2015 09:12:13 UTC