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 15514 - [Shadow]: <script> in shadow trees should not be inert
Summary: [Shadow]: <script> in shadow trees should not be inert
Status: RESOLVED FIXED
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: 14978
  Show dependency treegraph
 
Reported: 2012-01-11 07:40 UTC by Dominic Cooney
Modified: 2012-01-13 21:20 UTC (History)
0 users

See Also:


Attachments

Description Dominic Cooney 2012-01-11 07:40:32 UTC
<script> is different eg to <base>, which only belongs in <head>. I think it should be a goal of the spec that someone can take a subtree of HTML, slap it into a ShadowRoot, and have everything "work" provided that the subtree is a component (ie scoping selectors and ids is OK; stopping scripts running is not.)
Comment 1 Dimitri Glazkov 2012-01-11 19:06:47 UTC
(In reply to comment #0)
> <script> is different eg to <base>, which only belongs in <head>. I think it
> should be a goal of the spec that someone can take a subtree of HTML, slap it
> into a ShadowRoot, and have everything "work" provided that the subtree is a
> component (ie scoping selectors and ids is OK; stopping scripts running is
> not.)

In this example: http://jsfiddle.net/QkNDP/

The script runs when d is appended to the document.body.

Similarly, if we script was not inert in shadow DOM subtrees, it would run as soon as we appended it. That doesn't seem useful, but perhaps I am worrying about this too much?
Comment 2 Dimitri Glazkov 2012-01-12 22:27:01 UTC
http://dvcs.w3.org/hg/webcomponents/rev/18c8d3fd081f
Comment 3 Dominic Cooney 2012-01-13 04:35:21 UTC
With reference to http://jsfiddle.net/QkNDP/ the behavior I think is desirable is:

var s = document.createElement('script');
s.textContent = 'alert(1);';
var d = d.createElement('div');
var r = new ShadowRoot(d);
r.appendChild(s);
document.body.appendChild(d);
// script runs at this point

My reading of the spec was that script in shadow DOM subtrees was *always* inert, regardless of whether the "outermost host" is in the document or not.

As specified, what would the behavior be? Should I file another bug to clarify this?
Comment 4 Dimitri Glazkov 2012-01-13 21:20:00 UTC
(In reply to comment #2)
> http://dvcs.w3.org/hg/webcomponents/rev/18c8d3fd081f

I removed <script> from inert list here ^^^

Does that work?