Created
September 29, 2013 20:06
-
-
Save roman01la/6756060 to your computer and use it in GitHub Desktop.
Web Component Example
This file contains 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<link rel="import" href="components/my-element.html"> | |
</head> | |
<body> | |
<my-element></my-element> | |
</body> | |
</html> |
This file contains 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 id="my-tmpl"> | |
<!-- Template HTML & CSS --> | |
</template> | |
<script> | |
<!-- template-js content --> | |
<script> |
This file contains 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
var MyProto = Object.create(HTMLElement.prototype); | |
MyProto.createCallback = function() { | |
var template = document.querySelector('#my-tmpl'); | |
var shadowRoot = this.createShadowRoot(); | |
shadowRoot.appendChild(template.content.cloneNode(true)); | |
}; | |
document.register('my-element', {prototype: MyProto}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment