W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2015

Re: Custom element lifecycle callbacks

From: Anne van Kesteren <annevk@annevk.nl>
Date: Fri, 9 Jan 2015 10:28:14 +0100
Message-ID: <CADnb78gi1sFqaJbribynzE5tEjFBSF-B0N+ktuZFv0s2+whHSw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: WebApps WG <public-webapps@w3.org>
On Thu, Jan 8, 2015 at 5:54 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 1/8/15 10:56 AM, Anne van Kesteren wrote:
>> 2) For normal elements we act directly when they are cloned or
>> adopted. How much interest is there in delaying what happens for
>> normal elements to align them with custom elements?
>
> Which things are we talking about delaying?

As much as possible.


> I'm pretty sure the prototype change that happens in Gecko on adopt right
> now is part of our security model and can't easily be delayed.

I think we did actually discuss delaying this as part of how we wanted
to solve this bug:

  https://www.w3.org/Bugs/Public/show_bug.cgi?id=20567

The idea was that for normal elements the callback would change the
prototype, but for custom elements the custom element would have to
write that implementation themselves. Thinking of this now however
makes me think that such a solution would not exactly be ideal for a
proper subclassing story (you would expect to inherit the callback
behavior of normal elements).


> The other
> main thing that happens sync on clone is state propagation (e.g. copying of
> values for inputs, right)?  There are some security considerations there too
> that would need to be considered for every bit of state that's propagated;
> consider:
>
>   var input = document.createElement("input");
>   input.value = "file:///etc/passwd";
>   var newInput = input.cloneNode();
>   newInput.type = "file";
>
> I would like to see an actual list of the things we're considering delaying
> so we can think about the implications of doing that.

Note that in the above example cloning callbacks would happen after
the cloneNode() call but still before type is being set. So that might
be okay?

Custom elements have callbacks for these things (speculate ones marked with *):

* created
* attached
* detached
* attribute changed
* adopted*
* cloned*

So far I've only been looking at the implications for aligning the
last three. The first three seem a lot harder (and it's not entirely
clear to me the "created" design even works that well, see the
upgrading thread).


-- 
https://annevankesteren.nl/
Received on Friday, 9 January 2015 09:28:42 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:25 UTC