Re: [w3c/webcomponents] Should custom elements be adoptable if so, how? (#512)

> One question I have is running callbacks when the window is gone. If an element from document A is squirreled away somewhere, then A's window is closed/navigated/etc. and later the element is adopted into document B. The document change happens at that point, but it doesn't seem right to be running script from a closed window. It's true script that was already running continues to run after the window is closed, but I'm not sure how readily Blink would start new invocations when there's no window.

How is that different from grabbing a JS closure function out of an iframe that then gets removed?  The closure keeps around the global object of the removed iframe (and its document) in that case as well.

> This was one drawback of the original custom elements spec. Even if you control all of your documents and can register the same definition in all of them, once you close a window/iframe/etc. all of the elements which came from that context stop firing callbacks and are dead in the water. The built-in elements don't work that way.

That just seems like a bug in the engine.  Do you also prevent authors from calling a function that comes from a removed iframe/window?

> I think with the spec today, if you create a my-button in document A and move it to document B, it may or may not get upgraded. It depends on whether document A had a definition for my-button or not.
>
>With Domenic's proposal, it's simple and consistent: my-button gets the definition in document B, regardless of what happened to it in the past.

I think this is really a problem of perception.  If you created an empty iframe with no scripts, I can adopt an input element into it and it continues to function.  With this new definition, I can't do the same with custom elements.  In effect, I would have to include all the custom elements' definitions in every single document into which I may adopt my custom element.  That seems like an awful lot of overhead and error prone approach.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/512#issuecomment-223516196

Received on Friday, 3 June 2016 08:03:50 UTC