- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Sat, 22 Dec 2012 03:14:14 -0800
- To: Anne van Kesteren <annevk@annevk.nl>
- CC: www-dom@w3.org
On 12/22/12 2:36 AM, Anne van Kesteren wrote: > On Sat, Dec 22, 2012 at 1:07 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote: >> In particular, what happens to the prototype of the ES reflection of an >> element when it's adopted? Does it depend on whether its proto chain was >> earlier mutated by script or by web components stuff? > > Does anything need to happen? Well... Should the proto remain the proto associated with the window of the old document, or should it become the proto associated with the window of the new document? If it stays the old proto, then you'll have an element in the new document that tests false for instanceof against things in that window, no? For what it's worth the attached testcase shows the following behavior at first glance: Gecko: Changes the proto at adopt time Chrome, Opera: Don't seem to change the proto in this testcase Safari: Doesn't change proto at adopt time, ends up changing it later when it GCs, as far as I can tell. I don't have IE on hand to test, but would be interested in knowing what should happen with IE. And the question about how this all interacts with web components, if at all, remains. -Boris Testcase: <iframe></iframe> <pre><script> function report(el) { document.writeln(Object.getPrototypeOf(el) == HTMLDivElement.prototype); document.writeln(Object.getPrototypeOf(el) == frames[0].HTMLDivElement.prototype); } function f() { var div = document.createElement("div"); report(div) frames[0].document.documentElement.appendChild(div); report(div) } f(); var docEl = frames[0].document.documentElement; report(docEl.lastChild); // Now try to trigger some garbage collection for (var i = 0; i < 1000000; ++i) { document.createElement("span"); } report(docEl.lastChild); </script>
Received on Saturday, 22 December 2012 11:14:45 UTC