Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[attribute~="value"] selector not working on :host or :host-context #3023

Closed
Sleeckx opened this issue Nov 19, 2015 · 3 comments
Closed

[attribute~="value"] selector not working on :host or :host-context #3023

Sleeckx opened this issue Nov 19, 2015 · 3 comments
Assignees
Labels

Comments

@Sleeckx
Copy link

Sleeckx commented Nov 19, 2015

Hello,

the following test case illustrates the problem: http://jsbin.com/rexehifigo/edit?html,output

<dom-module id="my-element">
  <template>
    <style>
      :host {
        display: flex;
      }

      :host .detail {
        flex: 1;
      }

      :host[layout="master-detail"] .master {
        width: var(--master-width, 40%);
      }

      :host[layout~="master-detail"] .master {
        width: var(--master-width, 40%);
      }

      :host-context([layout~="master-detail"]) .master {
        width: var(--master-width, 40%);
      }
    </style>
    <div class="master">MASTER</div>
    <div class="detail">DETAIL</div>
  </template>
  <script>
    Polymer({
      is: 'my-element'
    });
  </script>
</dom-module>

Polymer generates the following custom style for the element:

<style scope="my-element-0">
    my-element.my-element-0[layout="master-detail"] .master.my-element {
      width:40%;
    }

    my-element.my-element-0[layout~="master-detail"].my-element .master.my-element {
      width:40%;
    }

    [layout~="master-detail"] my-element.my-element-0.my-element .master.my-element,
    my-element.my-element-0[layout~="master-detail"].my-element .master.my-element {
      width:40%;
    }
</style>

The first one is generated correctly, the second and third add .my-element after the attribute selector.

Edit: Included :host-context test case.

@MeTaNoV
Copy link

MeTaNoV commented Nov 19, 2015

Did you try :host-context([layout~="master-detail"]) ?

@Sleeckx
Copy link
Author

Sleeckx commented Nov 19, 2015

Yes, it also adds the .my-element class after the attribute selector:

<style scope="my-element-0">
    [layout~="master-detail"] my-element.my-element-0.my-element,
    my-element.my-element-0[layout~="master-detail"].my-element {
      width:40%;
    }
</style>

@Sleeckx Sleeckx changed the title [attribute~="value"] selector not working on :host [attribute~="value"] selector not working on :host or :host-context Nov 20, 2015
sorvell pushed a commit that referenced this issue Feb 12, 2016
…for general sibling combinator. Fixes #3023. Fix taken from #3067.
@equinusocio
Copy link

equinusocio commented Mar 24, 2017

I have the same issue with the ShadowDOM v1 implementation. :host-context([my-attr]) {...} doesn't work anymore. Reference https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom#contextstyling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants