I have a simple web component following the last syntax of the web components class v1 , it works fine in Chrome and Firefox / Edge (with polyfill), but I would like it to work in IE11, so I need to translate the class. However, running it through babel creates code that no longer works in any browser.
Is there a way to create backward compatible web components with class syntax, or is there a preferred way to write web components for maximum compatibility?
Code Example -
class TestElement extends HTMLElement { connectedCallback(){ this.innerHTML = "<div>Testing</div>" } } customElements.define('test-element', TestElement)
Error message when using the passed code -
Uncaught TypeError: Failed to create "HTMLElement": use the "new" operator, this constructor of the DOM object cannot be called a function.
source share