<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22892</bug_id>
          
          <creation_ts>2013-08-06 16:00:50 +0000</creation_ts>
          <short_desc>[Shadow]: What (if anything) does &lt;style scoped&gt; do, when it is a child of a shadow host?</short_desc>
          <delta_ts>2014-05-29 08:18:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>LATER</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>22716</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Dimitri Glazkov">dglazkov</reporter>
          <assigned_to name="Hayato Ito">hayato</assigned_to>
          <cc>hayato</cc>
    
    <cc>jackalmage</cc>
    
    <cc>tasak</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91693</commentid>
    <comment_count>0</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 16:00:50 +0000</bug_when>
    <thetext>Consider this situation:

&lt;style&gt; p { color: green; }
&lt;div id=&quot;foo&quot;&gt;
   &lt;style scoped&gt;
      p { color: red; }
   &lt;/style&gt;
&lt;/div&gt;
&lt;script&gt;
   var root = document.querySelector(&apos;#foo&apos;).createShadowRoot();
   root.innerHTML = &quot;&lt;content&gt;&lt;/content&gt;&lt;p&gt;What color am I?&lt;/p&gt;
&lt;/script&gt;

My intuition tells me that we should simply disallow these shenanigans, and the color of p is green. In other words, a scoped style that is a child of a shadow host does not do anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91694</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 16:05:06 +0000</bug_when>
    <thetext>Tab, WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91695</commentid>
    <comment_count>2</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2013-08-06 16:10:25 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; Consider this situation:
&gt; 
&gt; &lt;style&gt; p { color: green; }
&gt; &lt;div id=&quot;foo&quot;&gt;
&gt;    &lt;style scoped&gt;
&gt;       p { color: red; }
&gt;    &lt;/style&gt;
&gt; &lt;/div&gt;
&gt; &lt;script&gt;
&gt;    var root = document.querySelector(&apos;#foo&apos;).createShadowRoot();
&gt;    root.innerHTML = &quot;&lt;content&gt;&lt;/content&gt;&lt;p&gt;What color am I?&lt;/p&gt;
&gt; &lt;/script&gt;
&gt; 
&gt; My intuition tells me that we should simply disallow these shenanigans, and
&gt; the color of p is green. In other words, a scoped style that is a child of a
&gt; shadow host does not do anything.

What&apos;s the effect of a scoped stylesheet in the shadow root itself?  That still works, right?

Have we fully clarified whether &lt;content&gt; is *replaced* by its matched light DOM, or just *filled* with it (and then doesn&apos;t render, via magic like &quot;box:contents&quot;)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91696</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 16:18:54 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #0)
&gt; &gt; Consider this situation:
&gt; &gt; 
&gt; &gt; &lt;style&gt; p { color: green; }
&gt; &gt; &lt;div id=&quot;foo&quot;&gt;
&gt; &gt;    &lt;style scoped&gt;
&gt; &gt;       p { color: red; }
&gt; &gt;    &lt;/style&gt;
&gt; &gt; &lt;/div&gt;
&gt; &gt; &lt;script&gt;
&gt; &gt;    var root = document.querySelector(&apos;#foo&apos;).createShadowRoot();
&gt; &gt;    root.innerHTML = &quot;&lt;content&gt;&lt;/content&gt;&lt;p&gt;What color am I?&lt;/p&gt;
&gt; &gt; &lt;/script&gt;
&gt; &gt; 
&gt; &gt; My intuition tells me that we should simply disallow these shenanigans, and
&gt; &gt; the color of p is green. In other words, a scoped style that is a child of a
&gt; &gt; shadow host does not do anything.
&gt; 
&gt; What&apos;s the effect of a scoped stylesheet in the shadow root itself?  That
&gt; still works, right?

Depends on what we deem the effect of &quot;shadowing a DOM tree&quot; to be to styling. What would be the most logical thing to do here from CSS perspecive?

&gt; Have we fully clarified whether &lt;content&gt; is *replaced* by its matched light
&gt; DOM, or just *filled* with it (and then doesn&apos;t render, via magic like
&gt; &quot;box:contents&quot;)?

Nope, not yet. If it helps to sway in either direction, this is all flexible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91698</commentid>
    <comment_count>4</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2013-08-06 16:45:50 +0000</bug_when>
    <thetext>Actually, I think I&apos;ve been barking up the wrong tree anyway.

The entire point of &lt;style scoped&gt; is solely to make it easier and less error-prone to target only a particular element and its descendants.  You should be able to replace &lt;style scoped&gt;:scope p&lt;/style&gt; with &lt;style&gt;#parent p&lt;/style&gt; without any change in meaning or targeted elements.

So, same thing here.  The &lt;style scoped&gt; is scoped to the host element, and naturally applies its selectors on the light dom side, since that&apos;s where it lives.  It shouldn&apos;t target anything in the shadow dom unless you let selectors through.

(Where it gets distributed into the shadow dom shouldn&apos;t make a difference - it&apos;s scoped to its original parent.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91699</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 16:54:19 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; Actually, I think I&apos;ve been barking up the wrong tree anyway.

Okay. So the color of p is red, but only because it is inherited from div#foo. Right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91700</commentid>
    <comment_count>6</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 16:55:48 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; Actually, I think I&apos;ve been barking up the wrong tree anyway.
&gt; 
&gt; Okay. So the color of p is red, but only because it is inherited from
&gt; div#foo. Right?

Lol, sorry -- typing faster than thinking. No, it will be green, because #foo is a div, not a p.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91701</commentid>
    <comment_count>7</comment_count>
    <who name="Tab Atkins Jr.">jackalmage</who>
    <bug_when>2013-08-06 17:26:06 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; (In reply to comment #4)
&gt; &gt; &gt; Actually, I think I&apos;ve been barking up the wrong tree anyway.
&gt; &gt; 
&gt; &gt; Okay. So the color of p is red, but only because it is inherited from
&gt; &gt; div#foo. Right?
&gt; 
&gt; Lol, sorry -- typing faster than thinking. No, it will be green, because
&gt; #foo is a div, not a p.

In your example, it&apos;ll be black, because you aren&apos;t letting selectors through, and the top-level &lt;style&gt; is just targeting &lt;p&gt;s, so there&apos;s nothing there to style the shadow &lt;p&gt;. ^_^</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91702</commentid>
    <comment_count>8</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-06 17:26:47 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; In your example, it&apos;ll be black, because you aren&apos;t letting selectors
&gt; through, and the top-level &lt;style&gt; is just targeting &lt;p&gt;s, so there&apos;s
&gt; nothing there to style the shadow &lt;p&gt;. ^_^

jeseus.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106968</commentid>
    <comment_count>9</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2014-05-29 08:18:47 +0000</bug_when>
    <thetext>I am thinking that we can close this for a moment so that we can focus higher priority issues because, in practical, blink has stopped the support for &lt;style scoped&gt;.

Please feel free to re-open this if we need to think again how &lt;style scoped&gt; interacts with shadow trees.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>