Re: Minimum viable custom elements

On Jan 14, 2015, at 9:50 AM, Domenic Denicola <d@domenic.me> wrote:

> From: Anne van Kesteren [mailto:annevk@annevk.nl] 
> 
>> Could you explain how this works in more detail?
> 
> I haven't checked, but my impression was we could just use the same processing model the current spec uses for createdCallback, and use the constructor instead.

See Boris' responses in another thread [1] and [2].  Jonas outlined how this could work in the same thread [3]

The basic problem is that the DOM tree had already been constructed at that point, and you'll be able to access other uninitialized nodes via DOM APIs such as firstChild inside a custom element's constructor.

Now, ES classes have evolved quite a bit since the last we discussed this.  It's possible letting scripts access uninitialized objects is okay; we'll simply throw ReferenceError as it would be done when "this" is accessed before the "root" base class' constructor is called inside a subclass' constructor [4].

[1] http://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0816.html
[2] http://lists.w3.org/Archives/Public/public-webapps/2013OctDec/0818.html
[3] http://lists.w3.org/Archives/Public/public-webapps/2014JanMar/0098.html
[4] https://github.com/tc39/ecma262/blob/master/workingdocs/ES6-super-construct%3Dproposal.md

- R. Niwa

Received on Wednesday, 14 January 2015 18:35:45 UTC