Forked from mskrajnowski/ng-route-web-components-crash.html
Last active
August 29, 2015 14:24
-
-
Save petebacondarwin/442f842b6a49d76dbcf5 to your computer and use it in GitHub Desktop.
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> | |
<body> | |
<template id='my-component-template'> | |
<style> | |
@import url('whatever...'); | |
</style> | |
</template> | |
<div id="parent"><my-component></my-component></div> | |
<script> | |
function MyComponent() {} | |
MyComponent.prototype = Object.create(HTMLElement.prototype); | |
MyComponent.prototype.createdCallback = function() { | |
var template = document.getElementById('my-component-template'); | |
var clone = document.importNode(template.content, true); | |
var shadow = this.createShadowRoot(); | |
shadow.appendChild(clone); // this line crashes Chrome 42.0.2311.90 | |
}; | |
document.registerElement('my-component', MyComponent); | |
var parent = document.getElementById('parent'); | |
var webComponent = parent.firstElementChild; | |
var newNode = document.createElement('div'); | |
parent.replaceChild(newNode, webComponent); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment