shadycss icon indicating copy to clipboard operation
shadycss copied to clipboard

Scoped CSS incorrectly applied to Light DOM elements in IE11

Open CITguy opened this issue 8 years ago • 2 comments

Markup

<hx-modal>
  <!-- shadow root -->
  <div id="hxModal">
    <button id="hxClose" type="button">X</button>
    <slot></slot>
  </div>
  <!-- /shadow root -->

  <hx-modalhead>...</hx-modalhead>
  <hx-modalbody>...</hx-modalbody>
  <hx-modalfoot>...</hx-modalfoot>
</hx-modal>

Firefox 61

ShadyCSS in Firefox 61 correctly applies the .hx-modal class to ShadyDOM elements only (i.e., #hxModal.hx-modal, #hxClose.hx-modal, etc.).

screen shot 2018-06-29 at 1 30 23 pm

IE11

However, in IE 11, it is incorrectly applying the .hx-modal class to LightDOM children (i.e., hx-modalhead.hx-modal, hx-modalhead h3.hx-modal, etc.) which is causing Shady CSS styles to bleed into the light dom.

screen shot 2018-06-29 at 1 30 34 pm

CITguy avatar Jun 29 '18 18:06 CITguy

@CITguy could you provide a JSBin that shows the issue? You can start with http://jsbin.com/birajez/edit?html,output to illustrate the problem.

TimvdLippe avatar Sep 19 '18 16:09 TimvdLippe

I'm not able to replicate the issue any more. I'll close this issue, but I've attached additional information for context, should this problem show up again.


The bug was fixed between @webcomponents/webcomponentsjs version 1.2.2/2.0.2 and 1.2.3/2.0.3 when it updated @webcomponents/shadycss from 1.3.1 to 1.3.5.

I think it may have been fixed in #191 (released with v1.3.2), but I can't fully replicate with an online sandbox.

webcomponentsjs 2.0.2 (or 1.2.2)

https://s.codepen.io/CITguy/debug/qMvobB

Version 2.0.2/1.2.2 is the last version that shows symptoms of the original issue. It doesn't add all the classes as described above, but it does add empty class="" attributes to Light DOM children.

IE 11

<div class="style-scope ui-modal" id="uiModal">
  <button class="style-scope ui-modal" id="uiClose" type="button">X</button>
  <slot class="style-scope ui-modal"></slot>
</div>
<html>
  <head>...</head>
  <body>
    <ui-modal>
      <header class="">Modal Head</header>
      <div class="">Modal Body</div>
      <footer class="">Modal Footer</footer>
    </ui-modal>
  </body>
</html>

Firefox 62.0.2

<div id="uiModal" class="style-scope ui-modal">
    <button id="uiClose" type="button" class="style-scope ui-modal">X</button>
    <header class="">Modal Head</header>
    <div class="">Modal Body</div>
    <footer class="">Modal Footer</footer>
</div>

webcomponentsjs 2.0.3 (or 1.2.3)

https://s.codepen.io/CITguy/debug/PdgjRK

Version 2.0.3/1.2.3 is the first version of @webcomponents/webcomponentsjs that no longer adds empty class="" attributes.

IE 11

<div class="style-scope ui-modal" id="uiModal">
  <button class="style-scope ui-modal" id="uiClose" type="button">X</button>
  <slot class="style-scope ui-modal"></slot>
</div>
<html>
  <head>...</head>
  <body>
    <ui-modal>
      <header>Modal Head</header>
      <div>Modal Body</div>
      <footer>Modal Footer</footer>
    </ui-modal>
  </body>
</html>

Firefox 62.0.2

<div id="uiModal" class="style-scope ui-modal">
    <button id="uiClose" type="button" class="style-scope ui-modal">X</button>
    <header>Modal Head</header>
    <div>Modal Body</div>
    <footer>Modal Footer</footer>
</div>

CITguy avatar Sep 23 '18 00:09 CITguy