Skip to content

Instantly share code, notes, and snippets.

@mskrajnowski
Created April 20, 2015 12:12
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mskrajnowski/81ca99c080020b27e1bb to your computer and use it in GitHub Desktop.
angular-route + web-components crash - Chrome 42.0.2311.90
<!DOCTYPE html>
<html>
<body ng-app="app">
<ng-view></ng-view>
<template id='my-component-template'>
<style>
@import url('whatever...');
</style>
</template>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script>
<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);
angular
.module('app', ['ngRoute'])
.config(function($routeProvider) {
$routeProvider.otherwise({
template: '<div ng-repeat="item in list"><my-component></my-component></div>'
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment