<?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>21390</bug_id>
          
          <creation_ts>2013-03-25 19:26:15 +0000</creation_ts>
          <short_desc>[Shadow]: add support for styling shadowDOM contents based on host element</short_desc>
          <delta_ts>2013-07-17 22:12:35 +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>DUPLICATE</resolution>
          <dup_id>20957</dup_id>
          
          <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>14978</blocked>
    
    <blocked>21499</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Steve Orvell">sorvell</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>dominicc</cc>
    
    <cc>hayato</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>84940</commentid>
    <comment_count>0</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-03-25 19:26:15 +0000</bug_when>
    <thetext>It should be possible to style shadowDOM contents based on a selector the host element matches.

In general, it is common to define a set of theme styles that apply if a given ancestor selector matches. If nodes within a shadowDOM can be styled conditionally based on the host element, then shadowDOM can easily support this design pattern.

At a recent discussion, a ::shadow() pseudo-selector was proposed for this purpose. It would be used in an @host rule as follows:

@host {  
  /* match .foo shadowDOM nodes inside host elements matching .bar */
  .bar::shadow(.foo) {
    ...
  }
}

The ::shadow() pseudo-selector should also support the :root pseudo-selector to enable children selectors, for example:

@host {  
  /* match .foo shadowDOM children inside host elements matching .bar */
  .bar::shadow(:root &gt; .foo) {
    ...
  }
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87700</commentid>
    <comment_count>1</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2013-05-15 02:26:32 +0000</bug_when>
    <thetext>I would like to confirm how ::shadow works. 

(In reply to comment #0)

&gt; @host {  
&gt;   /* match .foo shadowDOM children inside host elements matching .bar */
&gt;   .bar::shadow(:root &gt; .foo) {
&gt;     ...
&gt;   }
&gt; }

Since &quot;match .foo shadowDOM children inside host elements matching .bar&quot;, &quot;.bar::shadow(:root &gt; .foo)&quot; doesn&apos;t match a host element whose class is bar and whose shadow root has any direct child whose class is foo.

So, if we write the followings, what elements should the followings match?

@host {  
  .bar::shadow(:root &gt; .foo) &gt; div {
     ....
  }
  .bar::shadow(:root &gt; .foo) div {
     ....
  }
}

Are the above rules the same as the followings?

@host {  
  .bar::shadow(:root &gt; .foo &gt; div) {
     ....
  }
  .bar::shadow(:root &gt; .foo div) {
     ....
  }
}

Or should we disallow the above rules?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87840</commentid>
    <comment_count>2</comment_count>
    <who name="Steve Orvell">sorvell</who>
    <bug_when>2013-05-17 23:05:33 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Since &quot;match .foo shadowDOM children inside host elements matching .bar&quot;,
&gt; &quot;.bar::shadow(:root &gt; .foo)&quot; doesn&apos;t match a host element whose class is bar
&gt; and whose shadow root has any direct child whose class is foo.

I&apos;m not sure I follow this. Are you just saying that we&apos;re changing the @host rule from always matching the host element to matching other elements? If so, then yes, that&apos;s the goal of adding ::shadow, to be able to style shadowDOM elements based on the host&apos;s selectors.


&gt; So, if we write the followings, what elements should the followings match?
&gt; 
&gt; @host {  
&gt;   .bar::shadow(:root &gt; .foo) &gt; div {
&gt;      ....
&gt;   }
&gt;   .bar::shadow(:root &gt; .foo) div {
&gt;      ....
&gt;   }
&gt; }
&gt; 
&gt; Are the above rules the same as the followings?
&gt; 
&gt; @host {  
&gt;   .bar::shadow(:root &gt; .foo &gt; div) {
&gt;      ....
&gt;   }
&gt;   .bar::shadow(:root &gt; .foo div) {
&gt;      ....
&gt;   }
&gt; }
&gt; 
&gt; Or should we disallow the above rules?

Yes, the above rules (first set) don&apos;t make sense. I vote to disallow that.

This points out that the syntax here is awkward.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87911</commentid>
    <comment_count>3</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2013-05-20 08:07:11 +0000</bug_when>
    <thetext>Thank you for replying.

(In reply to comment #2)

&gt; I&apos;m not sure I follow this. Are you just saying that we&apos;re changing the
&gt; @host rule from always matching the host element to matching other elements?
&gt; If so, then yes, that&apos;s the goal of adding ::shadow, to be able to style
&gt; shadowDOM elements based on the host&apos;s selectors.

I just confirm ::shadow&apos;s situation.

When we write something like &quot;div:not(...)&quot;, we want to get &quot;div&quot; (:not(...) is just specifying div&apos;s condition. So &quot;...&quot; part is just a sub-selector).

div::shadow(...) is different from the above. We don&apos;t want to get &quot;div&quot;. We need to look into &quot;...&quot; part from &quot;div&quot;.

&gt; Yes, the above rules (first set) don&apos;t make sense. I vote to disallow that.

That makes sense.

I would like to ask one more. I found another concerns, i.e. multiple pseudo elements. 

@host {  
  // unknown pseudo + ::shadow
  .bar::x-unknown-pseudo::shadow(.foo) {
    ...
  }
  // multiple ::shadow
  .bar::shadow(.foo)::shadow(.foobar) {
    ...
  }
  // ::shadow + ::distributed
  .bar::shadow(.foobar)::distributed(.foo) {
    ...
  }
}

We should support all the above cases, support some of the above or disallow all the above?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87924</commentid>
    <comment_count>4</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2013-05-20 15:10:48 +0000</bug_when>
    <thetext>(In reply to comment #3)

I&apos;m sorry. I found http://www.w3.org/TR/2012/WD-selectors4-20120823/#pseudo-elements

Only one pseudo-element may appear per selector, and only if the subject of the selector is the last compound selector in the selector. If present the pseudo-element must appear after the compound selector that represents the subjects of the selector. 

So my examples are disallowed, because mutiple pseudo elements are specified.
(I don&apos;t know the future pseudo-elements and CSS selector... 
 c.f. A future version of this specification may allow multiple pseudo-elements per selector.)

The spec also says:
&quot;Syntactically, a pseudo-element may be followed by any combination of the user action pseudo-classes. Whether these pseudo-classes can match on the pseudo-element depends on the pseudo-class and pseudo-element”s definition: unless otherwise-specified, none of these pseudo-classes will match on the pseudo-element.&quot;

So we probably need to define what pseudo-classes can work with ::shadow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90892</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-07-17 22:12:35 +0000</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 20957 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>