<!DOCTYPE html> | |
<template> | |
<style> | |
@import url(hello.css); | |
</style> | |
<h1>Hello</h1> | |
</template> | |
<script> | |
var t = document.currentScript.ownerDocument.querySelector('template'); | |
var proto = Object.create(HTMLElement.prototype); | |
proto.createdCallback = function() { | |
var root = this.createShadowRoot(); | |
root.appendChild(document.importNode(t.content, true)); | |
}; | |
document.registerElement('x-test', {prototype: proto}); | |
</script> |