Created
July 7, 2016 01:50
-
-
Save phlco/b8c19f0c32f84db72087c02b92052799 to your computer and use it in GitHub Desktop.
custom element template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<style> | |
</style> | |
</template> | |
<script> | |
var doc = document.currentScript.ownerDocument; | |
var ElementPrototype = Object.create(HTMLElement.prototype); | |
ElementPrototype.createdCallback = function() { | |
var shadow = this.createShadowRoot(); | |
var template = doc.querySelector('template'); | |
var clone = template.content.cloneNode(true); | |
shadow.appendChild(clone); | |
}; | |
var Element = document.registerElement('custom-element', { | |
prototype: ElementPrototype | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment