You'll need to include two pollyfils before you include a code with your custom elements:
• webcomponents/webcomponentsjs/custom-elements-es5-adapter.js - this is for new browsers in order to understand ES5 syntax
• webcomponents/custom-elements/custom-elements.min.js - this is for old browsers without customElements
support
You can add them to your index.html
file in the following way:
<div id="custom-elements-adapter">
<!-- Trick to include custom elements es5 adapter only if custom elements are supported -->
<script type="text/javascript">
if ('customElements' in window === false) {
var adapter = document.getElementById('custom-elements-adapter');
adapter.parentNode.removeChild(adapter);
adapter = undefined;
}
</script>
<script type="text/javascript" src="vendor/custom-elements-es5-adapter.js"></script>
</div>
<div id="custom-elements-polyfill">
<!-- Trick to include custom elements polyfill only if custom elements are not supported -->
<script type="text/javascript">
if ('customElements' in window) {
var polyfill = document.getElementById('custom-elements-polyfill');
polyfill.parentNode.removeChild(polyfill);
polyfill = undefined;
}
</script>
<script type="text/javascript" src="vendor/custom-elements.min.js"></script>
</div>