Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] super constructors don't work with Custom Elements v1 #15

Closed
trusktr opened this issue Sep 30, 2017 · 2 comments
Closed

[bug] super constructors don't work with Custom Elements v1 #15

trusktr opened this issue Sep 30, 2017 · 2 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Sep 30, 2017

Buble compiles super() calls to something like ParentClass.call(this).

This causes any and all Custom Elements (v1) to not work because they require the use of new (ES2015 classes), with an error like the following in Chrome:

Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object constructor cannot be called as a function

For example, see this output.

Try to run the output code in your browser, and you'll get the error.


Hmm, I don't think this is a bug with Buble. It's just not possible to compile anything for Custom Elements v1 to ES5 it seems. :(

This is a bug with Custom Elements v1 and it being designed for future browsers in a way that is impossible to transpile downward.

@trusktr
Copy link
Contributor Author

trusktr commented Sep 30, 2017

Unfortunately, the only solution that would sort of work is to use Refelct.construct, but that is only supported in Edge 12+.

@trusktr
Copy link
Contributor Author

trusktr commented Sep 30, 2017

@justinfagnani made this incredible hack which makes transpiled code work in older browsers! https://github.com/trusktr/custom-elements-1/blob/3984e69c85376d36d83b8a602cc5202c1edd9eed/src/native-shim.js

To be specific, that one makes transpiled code work in IE11. For IE10, let, const, and Map needs to be replaced by ES5 equivalents then it will work.


Sorry for the red flag here!

@trusktr trusktr closed this as completed Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant