Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html>
<head>
  <script>
    // Force all polyfills on
    if (window.customElements) window.customElements.forcePolyfill = true;
    ShadyDOM = { force: true };
    ShadyCSS = { shimcssproperties: true};
  </script>
  <script src="https://unpkg.com/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
</head>
<body>
  <template> 
    Hello World!
  </template>
  <script>
    const template = document.querySelector('template');
    ShadyCSS.prepareTemplate(template, 'my-element');
    class MyElement extends HTMLElement {
      constructor() {
        super();
        ShadyCSS.styleElement(this);
        this.attachShadow({mode: 'open'});
        this.shadowRoot.appendChild(template.content.cloneNode(true));
      }
      
      connectedCallback() {
        console.log('connected');
      }
      
      disconnectedCallback() {
        console.log('disconnected');
      }
    }
    customElements.define('my-element', MyElement);
  </script>
  <my-element></my-element>
</body>
</html>
Output

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

Dismiss x
public
Bin info
TimvdLippepro
0viewers