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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>103608</bug_id>
          
          <creation_ts>2012-11-29 00:35:41 -0800</creation_ts>
          <short_desc>[Shadow DOM]: @host @-rule doesn&apos;t work</short_desc>
          <delta_ts>2012-12-10 23:14:19 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</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>63606</blocked>
    
    <blocked>103230</blocked>
          <everconfirmed>0</everconfirmed>
          <reporter name="Sergey G. Grekhov">sgrekhov</reporter>
          <assigned_to name="Web Components Team">webcomponents-bugzilla</assigned_to>
          <cc>morrita</cc>
    
    <cc>shinyak</cc>
    
    <cc>tasak</cc>
    
    <cc>webcomponents-bugzilla</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>778778</commentid>
    <comment_count>0</comment_count>
    <who name="Sergey G. Grekhov">sgrekhov</who>
    <bug_when>2012-11-29 00:35:41 -0800</bug_when>
    <thetext>@host @-rule described in https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#host-at-rule doesn&apos;t work. Example is below:

&lt;html&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

function test() {
	var SR = window.ShadowRoot || window.WebKitShadowRoot;
    var d = document;
        
    var host = d.createElement(&apos;div&apos;);
    d.body.appendChild(host);

    //Older tree
    var s1 = new SR(host);
    var div1 = d.createElement(&apos;div&apos;);
    div1.innerHTML = &apos;&lt;span id=&quot;shd1&quot;&gt;This is an old shadow tree&lt;/span&gt;&apos;; 
    s1.appendChild(div1);
    
    //Younger tree
    var s2 = new SR(host);
    var div1 = d.createElement(&apos;div&apos;);
    div1.innerHTML = &apos;&lt;span id=&quot;shd2&quot;&gt;This is a young shadow tree&lt;/span&gt;&apos; + 
        &apos;&lt;shadow&gt;&lt;span id=&quot;shd3&quot;&gt;This is the shadow tree fallback content&lt;/span&gt;&lt;/shadow&gt;&apos;; 
    s2.appendChild(div1);
    
    var style = d.createElement(&apos;style&apos;);
    style.innerHTML = &apos;&apos; + 
        &apos;&lt;style&gt;&apos; +
            &apos;@host {&apos; +
                &apos;display:none;&apos; +
            &apos;}&apos; +
        &apos;&lt;/style&gt;&apos;; 
    s2.appendChild(style);    
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;test()&quot;&gt;

&lt;/body&gt;
&lt;/html&gt;


Both old and young trees are rendered but according the Shadow DOM specification one of them (not sure which one, see https://www.w3.org/Bugs/Public/show_bug.cgi?id=20150) shouldn&apos;t be shown</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>778883</commentid>
    <comment_count>1</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2012-11-29 03:10:15 -0800</bug_when>
    <thetext>Would you try the test after updating style.innerHTML line?
i.e.
   style.innerHTML = &apos;&apos; + 
            &apos;@host {&apos; +
                &apos;div { display:none; }&apos; +
            &apos;}&apos;;


Because the spec, http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#host-at-rule, says:

host
    : HOST_SYM S* &apos;{&apos; S* ruleset* &apos;}&apos; S*
    ;

and ruleset is:

ruleset
  : selector [ &apos;,&apos; S* selector ]*
    &apos;{&apos; S* declaration? [ &apos;;&apos; S* declaration? ]* &apos;}&apos; S*
  ;

So @host needs &quot;selector&quot; and &quot;{ declaration ..}&quot;.

Best regards,
Takashi Sakamoto</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>778893</commentid>
    <comment_count>2</comment_count>
    <who name="Sergey G. Grekhov">sgrekhov</who>
    <bug_when>2012-11-29 03:26:29 -0800</bug_when>
    <thetext>Thank you for quick response. Updated example doesn&apos;t work anyway. See below

&lt;html&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot;&gt;

function test() {
    var SR = window.ShadowRoot || window.WebKitShadowRoot;
    var d = document;

    var host = d.createElement(&apos;div&apos;);
    d.body.appendChild(host);

    //Older tree
    var s1 = new SR(host);
    var div1 = d.createElement(&apos;div&apos;);
    div1.innerHTML = &apos;&lt;span id=&quot;shd1&quot;&gt;This is an old shadow tree&lt;/span&gt;&apos;; 
    s1.appendChild(div1);

    //Younger tree
    var s2 = new SR(host);
    var div1 = d.createElement(&apos;div&apos;);
    div1.innerHTML = &apos;&lt;span id=&quot;shd2&quot;&gt;This is a young shadow tree&lt;/span&gt;&apos; + 
        &apos;&lt;shadow&gt;&lt;span id=&quot;shd3&quot;&gt;This is the shadow tree fallback content&lt;/span&gt;&lt;/shadow&gt;&apos;; 
    s2.appendChild(div1);

    var style = d.createElement(&apos;style&apos;);
    style.innerHTML = &apos;&apos; + 
            &apos;@host {&apos; +
                &apos;div{display:none;}&apos; +
            &apos;}&apos;; 
    s2.appendChild(style);    
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;test()&quot;&gt;

&lt;/body&gt;
&lt;/html&gt;

After running of this test both of the trees are shown</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>784213</commentid>
    <comment_count>3</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2012-12-05 15:51:53 -0800</bug_when>
    <thetext>I ran DumpRenderTree with the test. I saw the following result:

Content-Type: text/plain
layer at (0,0) size 800x600
  RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
  RenderBlock {HTML} at (0,0) size 800x600
    RenderBody {BODY} at (8,8) size 784x584
#EOF
#EOF

I also tested by using chrome canary, i.e. 
Google Chrome	25.0.1349.0 (Official Build 171160) canary
OS	Mac OS X 
WebKit	537.21 (@136547)
JavaScript	V8 3.15.8

The test is http://jsfiddle.net/hWCZ7/5/.

I couldn&apos;t see any shadow trees.

Best regards,
Takashi Sakamoto</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>788073</commentid>
    <comment_count>4</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2012-12-10 23:14:19 -0800</bug_when>
    <thetext>I couldn&apos;t reproduce this issue. So I will change the status into RESOLVED WORKSFORME.
If I find any @host @-rules bug, I wil file a new bug or reopen this bug.

Best regards,
Takashi Sakamoto</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>