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/
>
>