[Bug 20488] [Custom]: Need to define what happens when nodes are adopted into or out of documents that have custom element definitions

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

--- Comment #8 from Dominic Cooney <dominicc@chromium.org> ---
Looking again at the spec, it now looks prescient by not talking about node
adoption. Does the following make sense? I believe it is mostly a paraphrase of
that is in the spec:

There's an object called a registration context.

There's some process through which documents get a registration context. This
is Bug 22466.

Since elements are created in a specific document, they are associated with a
registration context. That association is *fixed for the life of the element*
(I may have been overlooking this part), even though the element may move into
different documents later.

When a definition is registered in a registration context, any elements waiting
on that definition are upgraded.

Whether callbacks are generated depends on whether an element has a definition
or not, and not what document it is in or what registration context that
document has.

When all of the associated documents have gone away, it means no more custom
element registrations are possible, because the route to registering something
is via a document.

However an element that already had a definition can continue to go about its
business independent of the (now dead, or possibly zombified) registration
context.

You can see that this is a very ownerDocument and adoptNode-agnostic thing.
Documents only play a role at two crucial points:

1. When a node is created, either finding a definition from the associated
registration context, or adding it to the registration context's upgrade
candidates.

2. When a definition is provided, connecting the dots between definition and a
set of upgrade candidates.

So a registration context is more like a lottery that elements are entered into
when they are created. document.register('x-x', ...) announces that elements
holding an x-x ticket in the lottery are winners and will be upgraded. Winners
have nothing to do with the lottery after that. And there's the obvious
optimization that, if there are no more documents, no more winners can be
announced, so everyone left in that lottery is a loser.

So what about the lifetimes of things? Will this result in a massive leak? I
think it is OK; in Blink it will probably involve the usual trick of
insinuating references between objects on the JavaScript heap to make sure
certain objects survive "as least as long as" certain other objects.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 19 July 2013 05:26:06 UTC