blikblum/tinybind

IE11: Function.prototype.toString: 'this' is not a Function object

Closed this issue · 2 comments

When I switched from rivets to tinybind, I encountered an error in IE11:

Function.prototype.toString: 'this' is not a Function object

I've done some googling and it looks like this is a known issue with Babel and Web Components:

babel/babel#8915

In the thread, I found a workaround that works for me:

<!-- Polyfills for custom-elements -->
<script>if (this.customElements) try { customElements.define('built-in', document.createElement('p').constructor, { 'extends': 'p' }) } catch (a) { document.write('<script src="https://unpkg.com/@@ungap/custom-elements-builtin@0.2.7/min.js" crossorigin="anonymous" ><' + '/script>') } else document.write('<script src="https://unpkg.com/document-register-element@1.13.2/build/document-register-element.js" crossorigin="anonymous" ><' + '/script>');</script>

<!--
    On IE11, typeof HTMLElement === 'object',
    this breaks Babel 7 compilation of built in extension.
    Adding an adapter to add an intermediate constructor wrapping native HTMLElement to fix this issue
-->
<script>if (typeof HTMLElement === 'object') document.write('<script src="https://unpkg.com/custom-elements-es5-adapter@@1.0.0/custom-elements-es5-adapter.js" crossorigin="anonymous"><' + '/script>')</script>

Source: babel/babel#8915 (comment)

The issue is still open so not sure if tinybind can do anything about it? In any case, the README should probably mention that IE11 is not supported.

In the documentation, says it should use the polyfill on IE11: https://blikblum.github.io/tinybind/docs/guide/#components

Internet Explorer requires the use of a compiler like babel to transpile the class as well to use the webcomponents polyfill

I will do an example

Closing this issue due to inactivity