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

Re: [webcomponents]: What callbacks do custom elements need?

From: Elliott Sprehn <esprehn@gmail.com>
Date: Mon, 11 Mar 2013 14:18:16 -0700
Message-ID: <CAPJYB1i5S=yp4NydNqtOJ6fonXAT30uAiCq6n3NvzheZv8F6rQ@mail.gmail.com>
To: Daniel Buchner <daniel@mozilla.com>
Cc: Jonas Sicking <jonas@sicking.cc>, Dimitri Glazkov <dglazkov@google.com>, William Chen <wchen@mozilla.com>, Hajime Morrita <morrita@google.com>, Elliott Sprehn <esprehn@google.com>, Blake Kaplan <mrbkap@mozilla.com>, public-webapps <public-webapps@w3.org>, Steve Orvell <sorvell@google.com>, Scott Miles <sjmiles@google.com>
On Wed, Mar 6, 2013 at 5:36 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 3/6/13 5:05 PM, Dimitri Glazkov wrote:
>> * attributeChangedCallback -- synchronously called when an attribute
>> of an element is added, removed, or modified
> Synchronously in what sense?  Why are mutation observers not sufficient
> here?

> * insertedCallback -- asynchronously called when an element is added
>> to document tree (TBD: is this called when parser is constructing the
>> tree?)
> Again, why is this not doable with mutation observers?

"inserted" and "removed" can probably be end of micro task, but
attributeChanged definitely needs to be synchronous to model the behavior
of <input type> where changing it from X to Y has an immediate effect on
the APIs available (like stepUp).

MutationObservers are not sufficient because childList mutations are about
children, but you want to observe when *yourself* is added or removed from
the Document tree. There's also no "inserted into document" and "removed
from document" mutation records, and since ShadowRoot has no "host"
property there's also no way to walk up to the root to find out if you're
actually in the document. (Dimtiri should fix this... I hope).

The ready callback should probably also be synchronous (but at least it
happens in script invocation of the new operator, or after tree building),
since you want your widget to be usable immediately.

- E
Received on Monday, 11 March 2013 21:19:27 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:59 UTC