blikblum / tinybind

Lightweight and powerful data binding + templating solution
http://blikblum.github.io/tinybind/
MIT License
79 stars 14 forks source link

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

Closed rejhgadellaa closed 1 year ago

rejhgadellaa commented 3 years ago

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:

https://github.com/babel/babel/issues/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: https://github.com/babel/babel/issues/8915#issuecomment-505274882

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.

blikblum commented 3 years ago

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

karneaud commented 1 year ago

Closing this issue due to inactivity