Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<H1>Basic declarative Shadow DOM example</H1>
<p>This example makes use of, and requires an implementation of, <a href="https://github.com/mfreed7/declarative-shadow-dom/blob/master/README.md">declarative Shadow DOM</a>.
In Chrome 85+, enable the Experimental Web Platform Features (chrome://flags/#enable-experimental-web-platform-features) flag to try it out.</p>  
<p>This example should show two green-background &lt;H2&gt; text fragments below:</p>
<host-element>
    <template shadowroot="open">
        <style>
          ::slotted(h2), h2 {
            background:green !important;
          }
        </style>
        <h2>Shadow Content (visible if in shadow root)</h2>
        <slot></slot>
    </template>
    <style>
      h2 {
        background: red;
      }
    </style>
    <h2>Light DOM content (green if slotted)</h2>
</host-element>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
mfreed7pro
0viewers