W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: Custom Elements: insert/remove callbacks

From: Dominic Cooney <dominicc@google.com>
Date: Thu, 7 May 2015 17:10:28 +0900
Message-ID: <CAHnmYQ_5QPtFsCQYB7Zo4hOjx0ho4WbwKo1osNWg27fJbnTPBg@mail.gmail.com>
To: Anne van Kesteren <annevk@annevk.nl>
Cc: Justin Fagnani <justinfagnani@google.com>, Dimitri Glazkov <dglazkov@google.com>, WebApps WG <public-webapps@w3.org>
On Thu, May 7, 2015 at 4:43 PM, Anne van Kesteren <annevk@annevk.nl> wrote:

> On Wed, May 6, 2015 at 11:01 PM, Justin Fagnani
> <justinfagnani@google.com> wrote:
> > How are you supposed to tell if one of your ancestors was removed?
>
> Is that a hook builtin elements have today?


Blink's built-in elements' hook is "inserted into"/"removed from document",
including via an ancestor being manipulated as you can see here
(this--Node::removedFrom--is the "removed" case):

https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp&sq=package:chromium&type=cs&l=834&rcl=1430970612

This is overridden 68 times by various kinds of nodes including many
elements. What it's used for varies; one example is the HTMLMarqueeElement
that stops a callback that's driving its animation. If you were trying to
implement MARQUEE as a Custom Element, you'd want this callback to call
clearTimeout, cancelAnimationFrame, or whatever.

There are similar hooks and uses for insertion.

The HTML spec itself points to a lot of uses for this; when it switches on
things being "in a document" <https://html.spec.whatwg.org/#in-a-document> and
something needs to be done/updated/etc. to implement that effect.


>
> --
> https://annevankesteren.nl/
>
>
Received on Thursday, 7 May 2015 08:10:56 UTC

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