Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created February 3, 2016 14:29
Show Gist options
  • Select an option

  • Save AndyNovo/0a32b575de68582dc7ff to your computer and use it in GitHub Desktop.

Select an option

Save AndyNovo/0a32b575de68582dc7ff to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="ninja.html">
</head>
<body>
<ninja-killa></ninja-killa>
<ninja-killa></ninja-killa>
<ninja-killa></ninja-killa>
<ninja-killa></ninja-killa>
<p>This is a boring old paragraph</p>
</body>
</html>
<template>
<style> * { color: salmon; } </style>
<div class="ninja">
This is a ninja. It is amazing.
</div>
</template>
<script>
var template = document.currentScript.ownerDocument.getElementsByTagName('template')[0];
var $baseElement = Object.create(HTMLElement.prototype);
$baseElement.createdCallback = function(){
var shadow = this.createShadowRoot();
var clone = document.importNode(template.content, true);
shadow.appendChild(clone);
};
document.registerElement('ninja-killa', {
prototype: $baseElement
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment