<?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>21959</bug_id>
          
          <creation_ts>2013-05-07 22:17:16 +0000</creation_ts>
          <short_desc>[Shadow]: @host rules should be overridden by selectors in document</short_desc>
          <delta_ts>2013-07-17 22:17:40 +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>INVALID</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>14978</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Freedman">dfreedm</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>dominicc</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>87386</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Freedman">dfreedm</who>
    <bug_when>2013-05-07 22:17:16 +0000</bug_when>
    <thetext>As it stands now, @host is more specific a selector than any other but the style attribute on that element.
This makes it very difficult to style composed elements with @host rules, as manipulation of the style element is required to do things such as collapse adjacent borders or translate the element&apos;s position.

As a developer, I would rather use @host to be the &quot;default&quot; styling of an element, like a custom user-agent style.

If there are stylings a developer would want to protect, then that developer should put that styling in an element in the ShadowRoot.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88266</commentid>
    <comment_count>1</comment_count>
    <who name="Takashi Sakamoto">tasak</who>
    <bug_when>2013-05-28 06:40:11 +0000</bug_when>
    <thetext>I would like to confirm one thing:

Suppose that we have a tag selector in an author stylesheet, e.g.

&lt;style&gt;
div { color: green; }
&lt;/style&gt;

and that we also have a shadow host whose id is &quot;host&quot; and whose shadow root has an id selector in @host @-rule, e.g.

&lt;div id=&quot;host&quot;&gt;
    #shadow-root
        &lt;style&gt;
            @host { #host { color: red; } }
        &lt;/style&gt;
        Hello, World!

So the text: &quot;Hello, World!&quot; should be shown in green color or red color?

I mean, which is better:
(a) any selector in an author stylesheet wins, or

(b) it depends on specificity. If a selector in @host @-rules has higher specificity, the selector wins.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88267</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-05-28 06:40:41 +0000</bug_when>
    <thetext>I was chatting with tasak about this. The super specificity of @host rules [1] was added to the spec so that there&apos;s a defined cascade for @host rules.

You could also say they have &quot;super negative specificity&quot; and maybe get something like the &quot;default&quot; behavior that you want.

However he pointed out a problem to me: Since that line was written, @host semantics have gotten richer, so now you could have @host rules in different ShadowRoots overlapping, and there is no defined cascade order for them.

So I think the solution here is to define an &quot;order specified&quot; for the CSS cascade that includes ShadowRoots.

Although it is harder than just saying &quot;@host rules have high/low specificity&quot;, I think it is necessary, because:

1. It defines what the behavior with multiple overlapping @host rules contributing styles from multiple ShadowRoots should be.

2. It allows more fine-grained control, for example, selector specificity makes sense again... #id selectors will be specific again.

I *think* that the order should be: I. ShadowRoots come before the document/ShadowRoot their hosts are in (this gives you the &quot;default&quot; behavior you want for theming); II. older ShadowRoots should come before younger ones.

I. gives you an outside-in precedence, so that if you have an outer component providing a theme, it will apply over the @host rules of the inner component. Is this what you&apos;d want?

[1] &quot;When a rule in @host @-rule matches an element, it must have higher specificity than any selector, but lower specificity than declarations from a style attribute.&quot; &lt;https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#host-at-rule&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90897</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-07-17 22:17:40 +0000</bug_when>
    <thetext>@host is dead. This is moot.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>