shadycss icon indicating copy to clipboard operation
shadycss copied to clipboard

:host-context() replacement generates broken CSS selector

Open CITguy opened this issue 8 years ago • 2 comments

ShadyCSS is generating incorrect CSS selectors for :host-context().

Setup

See https://codepen.io/CITguy/pen/OwZoXR/

ShadowDOM for <ui-demo>

<style>
  :host-context(.foobar) {
    background-color: lime;
  }
</style>
<slot></slot>

Light DOM, consuming <ui-demo>

<p>
  Should have transparent background:
  <ui-demo>
    <code>p ui-demo</code>
  </ui-demo>
</p>

<p class="foobar">
  Should have lime background:
  <ui-demo>
    <code>p.foobar ui-demo</code>
  </ui-demo>
</p>

<p>
  Should have lime background:
  <ui-demo class="foobar">
    <code>p ui-demo.foobar</code>
  </ui-demo>
</p>

Expected Output

Per the W3C Specification for :host-context()...

When evaluated in the context of a shadow tree, the :host-context() pseudo-class matches the host element, if the host element or one of its ancestors matches the provided compound-selector.

The expected Shady DOM styles should be...

<head>
  <!--Shady DOM styles for ui-demo-->
  <style scope="ui-demo">
    .foobar ui-demo, ui-demo.foobar { background-color: lime; }
  </style>
</head>

Actual Output

<head>
  <!--Shady DOM styles for ui-demo-->
  <style scope="ui-demo">
    ui-demo-context(.foobar) { background-color: lime; }
  </style>
</head>

Only the :host portion of :host-context(.foobar) is getting replaced.

CITguy avatar Aug 02 '18 22:08 CITguy

This might be related to #74, too.

CITguy avatar Aug 02 '18 22:08 CITguy

Was it intentional to close this issue?

What prompted the close? Has this been resolved somewhere?

CITguy avatar Jun 06 '19 22:06 CITguy