Guest User

Untitled

a guest
Nov 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. const template = document.createElement('template')
  6. template.innerHTML = `
  7. <style>#foobar {background: red;}</style>
  8. <h1 id="foobar">I am foo bar</h1>
  9. <slot></slot>
  10. `
  11.  
  12. customElements.define('foo-bar', class extends HTMLElement {
  13. constructor() {
  14. super()
  15. this.attachShadow({mode: 'open'})
  16. this.shadowRoot.appendChild(template.content.cloneNode(true))
  17. }
  18. })
  19. </script>
  20. </head>
  21. <body>
  22. <foo-bar>
  23. <h2>I use the slot tunnel</h2>
  24. </foo-bar>
  25. </body>
  26. </html>
Add Comment
Please, Sign In to add comment