Skip to content

Instantly share code, notes, and snippets.

@roman01la
Created September 29, 2013 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman01la/6756060 to your computer and use it in GitHub Desktop.
Save roman01la/6756060 to your computer and use it in GitHub Desktop.
Web Component Example
<!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>
<template id="my-tmpl">
<!-- Template HTML & CSS -->
</template>
<script>
<!-- template-js content -->
<script>
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