Skip to content

Instantly share code, notes, and snippets.

@sorvell
Created September 11, 2013 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sorvell/6527156 to your computer and use it in GitHub Desktop.
Save sorvell/6527156 to your computer and use it in GitHub Desktop.
Failing SD Polyfill distribution
<!DOCTYPE html>
<html>
<head>
<script src="../../../polymer/polymer.js"></script>
</head>
<body>
<template id="host-template">
<div>host shadowRoot</div>
<content></content>
</template>
<template id="inner-host-template">
<div>inner-host shadowRoot</div>
</template>
<x-host>
<x-inner-host></x-inner-host>
</x-host>
<script>
var xHostProto = Object.create(HTMLElement.prototype);
xHostProto.createdCallback = function() {
this.createShadowRoot();
this.shadowRoot.appendChild(document.querySelector('#host-template').createInstance());
// no problem without template
//this.shadowRoot.innerHTML = '<div>host shadowRoot</div><content></content>';
}
var xInnerHostProto = Object.create(HTMLElement.prototype);
xInnerHostProto.createdCallback = function() {
this.createShadowRoot();
this.shadowRoot.appendChild(document.querySelector('#inner-host-template').createInstance());
// no problem without template
//this.shadowRoot.innerHTML = '<div>inner-host shadowRoot</div>';
}
// no problem without custom elements
document.register('x-host', {prototype: xHostProto});
document.register('x-inner-host', {prototype: xInnerHostProto});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment