Created
July 17, 2014 14:37
-
-
Save vogtm/bee227189e8d5d3383b2 to your computer and use it in GitHub Desktop.
Playing around with web components
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> | |
<head> | |
<title>web components</title> | |
<style type="text/css"> | |
html{ | |
font-family:"Courier New", Courier, monospace; | |
color: blue; | |
} | |
</style> | |
</head> | |
<body> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | |
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | |
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo | |
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse | |
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non | |
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> | |
<template id="template"> | |
<p>I'm in Shadow DOM</p> | |
</template> | |
<script type="text/javascript"> | |
var proto = Object.create(HTMLElement.prototype, { | |
createdCallback: { | |
value: function() { | |
var t = document.querySelector('#template'); | |
var clone = document.importNode(t.content, true); | |
this.createShadowRoot().appendChild(clone); | |
} | |
} | |
}); | |
document.registerElement('x-myownBlock', {prototype: proto}); | |
</script> | |
<x-myownBlock></x-myownBlock> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment