shadycss icon indicating copy to clipboard operation
shadycss copied to clipboard

:host selector not selecting shadowed elements

Open RobJacobs opened this issue 8 years ago • 1 comments

I recently updated to Windows build 1709 that included an updated version of Edge:

Microsoft Edge 41.16299.15.0 Microsoft EdgeHTML 16.16299

With version 1.0.20 of web components, the :host shadow selector I am using is no longer working. It does work in Chrome (62.0.3203.94), it does not work in Firefox (57.0).

Here is a trivial example of what I am doing:

    customElements.define('test-comp', class extends HTMLElement {
      constructor() {
        super();
        var shadowRoot = this.attachShadow({mode: 'open'});
        shadowRoot.innerHTML = `
          <style>
            :host { display: block; } 
            :host(.blue-text) .span-text { color: blue; } 
            .span-text { color: red; }
          </style>
          <span class="span-text">Test Web Component - I should be blue</span>`
      }
    })

so when the host element has a class of blue-text, the inner span get's a blue color. Here is an example plunk.

RobJacobs avatar Dec 07 '17 17:12 RobJacobs

This SO post explained what is happening.

RobJacobs avatar Dec 08 '17 23:12 RobJacobs