polyfills icon indicating copy to clipboard operation
polyfills copied to clipboard

es5 browsers not supported?

Open kevinbeal opened this issue 4 years ago • 3 comments

Description

custom-elements-es5-adapter.js contains ES2015 syntax (e.g. const e=HTMLElement) and thus cannot be used as a shim for es5 code without compiling, but it specifically says not to compile it in the README. I can't easily compile it in my current setup anyway, so that might not even be an option.

Steps to reproduce

  1. Add to a project without compiling.
  2. Open any browser which does not support const keyword.

Expected behavior

A shim made for es5 browsers actually working in es5 browsers.

Actual behavior

es6 syntax throwing syntax errors

Version

2.4.3

Browsers affected

  • [ ] Chrome
  • [ ] Firefox
  • [ ] Edge
  • [ ] Safari
  • [ ] IE 11
  • [x] IE 10

kevinbeal avatar Aug 11 '20 20:08 kevinbeal

I believe the shim is not intended for es5 browsers, but rather, for es6 browsers that want to use a webcomponent bundle that has been transpiled down to es5. Browsers that correctly implement webcomponents will fail if a non-class is passed as the second arg to customElements.define. The shim basically makes it so that pre-es6 classes can be used here (functions with defined prototype methods).

bschlenk avatar Nov 25 '20 14:11 bschlenk

The code has a check to return early for older browsers (if window.Reflect === undefined for example). So it's meant to be at least runnable on older browsers. But Chrome <= 40 throws an error:

Uncaught SyntaxError: Use of const in strict mode

which is weird because it should never even execute that line since it doesn't have Reflect.

It would be easy enough to change the const to a var, or remove the "use strict" directive. (related: "use strict")

matthias-ccri avatar Feb 11 '21 01:02 matthias-ccri

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 16 '22 22:02 stale[bot]