Re: [Custom]: Rename "createdCallback" to "created"

> On 2014-10-06, at 18:24, James M. Greene <james.m.greene@gmail.com> wrote:
> This only thing about this approach that is slightly inconsistent with the rest of the Web Platform is assuming that the `this` context within the handler will be set to the element, rather than being forced to grab it via `event.target`.

ES6 arrow functions are going to solve the problems with “this” scoping inside event handlers.

Ideally I would prefer to have a constructor instead of createdCallback(), and “attach”, “detach” and “attributechange” events instead of the other lifecycle callbacks. The constructor idea was already discussed here for a long time [1], but if I understand correctly it wasn’t approved due to performance issues.

> let Button = document.registerElement(“x-button”, class Button extends HTMLElement {
>   constructor() {
>     this.addEventListener(“attach”, () => this.attached() );
>     this.addEventListener(“detach”, () => this.detached() );
>     this.addEventListener(“attributeChange”, () => this.attributeChanged() );
>   }
>   attach() {
>     console.log(“Attached host element”);
>   }
>   ...
> }

[1] http://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0793.html

Received on Monday, 6 October 2014 17:22:18 UTC