This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17447 - [Shadow]: What happens when ShadowRoot instantiated from a different context?
Summary: [Shadow]: What happens when ShadowRoot instantiated from a different context?
Status: RESOLVED DUPLICATE of bug 15611
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18428
  Show dependency treegraph
 
Reported: 2012-06-08 21:50 UTC by Dimitri Glazkov
Modified: 2012-11-27 19:11 UTC (History)
1 user (show)

See Also:


Attachments

Description Dimitri Glazkov 2012-06-08 21:50:46 UTC
"Create a new instance of the ShadowRoot object"

what if it is a ShadowRoot from a different iframe (different from window of the new host)?

Then we'll have to either return a different object from the constructor or do something else. element.createShadowRoot solves this problem, btw.
Comment 1 Dominic Cooney 2012-06-18 02:39:20 UTC
(In reply to comment #0)
> "Create a new instance of the ShadowRoot object"
> 
> what if it is a ShadowRoot from a different iframe (different from window of
> the new host)?
> 
> Then we'll have to either return a different object from the constructor or do
> something else.

What is the particular difficulty here?

Isn’t it enough to say

Create a new instance of the ShadowRoot object in the ownerDocument of element

or something like that?

> element.createShadowRoot solves this problem, btw.

First, constructors can return different objects, although it is probably preferable not to do that to make extension easier.

Assuming new ShadowRoot works like a typical JavaScript constructor (ie it does not return a different object), is the only difference between new ShadowRoot(element) and element.createShadowRoot that the prototype chain of the object created by new ShadowRoot(element) is fixed? I don’t think that is particularly a problem; the object can just use the environment of the page creating the ShadowRoot.

If e is an element from a frame f and you do

var s = new ShadowRoot(e);

this just means that

s.constructor === window.ShadowRoot
Object.getPrototypeOf(s) === window.ShadowRoot.prototype
s.ownerDocument === f.contentWindow.document

Admittedly it is weird to mix constructors from one window with content from another, but it works.
Comment 2 Dimitri Glazkov 2012-11-27 19:11:38 UTC
This is no longer an issue, since we switched to use .createShadowRoot in bug 15611

*** This bug has been marked as a duplicate of bug 15611 ***