Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta input="utf-8">
  <title>importNode from template doesn't instantiate custom element</title>
  <script>
    class TestElement extends HTMLElement {}
    customElements.define('test-element', TestElement);
    let template = document.createElement('template');
    template.innerHTML = `<test-element></test-element>`;
    let clone = document.importNode(template.content, true);
    let element = clone.querySelector('test-element');
    console.log(element instanceof TestElement); // true in Chrome Canary, false in WebKit
  </script>
</head>
<body/>
</html>
Output

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

Dismiss x
public
Bin info
JanMiksovskypro
0viewers