[ie11] When using webcomponents-loader.js, the Template polyfill is not applied yet when WebComponentsReady is fired
Hello,
I'm importing those scripts at the bottom of the HTML page
<script src="js/demo.js"></script>
<script>if (!window.customElements) { document.write('<!--'); }</script>
<script src="js/third-party/custom-elements-es5-adapter.js"></script>
<!--! do not remove -->
<script src="js/third-party/webcomponents-loader.js"></script>
In demo.js, I wait for the WebComponentsReady event, and then I need to get a <template> from the page in order to stamp it.
var onWCReady = function() {
var demoTemplate = document.querySelector('#demoTemplate');
document.body.appendChild(template.content.cloneNode(true));
};
if (window.WebComponents && window.WebComponents.ready === true) {
onWCReady();
} else {
window.addEventListener('WebComponentsReady', onWCReady);
}
But in IE11 I get this error:
Unable to get property 'cloneNode' of undefined or null reference, and in fact, demoTemplate is still a HTMLUnknownElement.
Also, please note that this doesn't happen if I switch webcomponents-loader with webcomponents-lite.
workaround: bower install webcomponents/template --save and load before the loader:
<script src="bower_components/template/template.js"></script>
<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script>
Hey @mkropf ,
thanks for your answer.
However, adding explicitly the <Template> polyfill defeats the purpose of using webcomponents-loader, and is similar to the fix that I'm applying so far (using webcomponents-lite)
This should be fixed now: https://github.com/webcomponents/webcomponentsjs/blob/447cf811674e6c05375082d72f839b0e2056b7fa/webcomponents-loader.js#L68-L75 If it is not, please open a new issue with a JSBin that shows the problem.