Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <dialog id="dialog" onclick="handler(event)">
    hello<button>test</button>
    <content></content>
  </dialog>
  <div id="host" onclick="hostHandler(event)"><button id="light">light dom</button></div>
  <button onclick="toggle()">click</button>
  <script>
    var dialog;
    function toggle() {
      //dialog.show();
      dialog.showModal();
    }
    function handler(e) {
      console.log('handler', e.target, e.path);
    }
    function hostHandler(e) {
      console.log('hostHandler', e.target, e.path);
    }
    document.addEventListener('DOMContentLoaded', function() {
      dialog = document.querySelector('#dialog');
      var root = document.querySelector('#host').webkitCreateShadowRoot();
      root.appendChild(dialog);
    });
  </script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers