Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class constructor PolymerElement cannot be invoked without 'new'

Yesterday my app worked perfectly however when I now do polymer serve -o it opens the app and prints this error in the console.

Class constructor PolymerElement cannot be invoked without 'new'
like image 675
Gaetano Herman Avatar asked Apr 20 '17 13:04

Gaetano Herman


2 Answers

  1. Clear the Cached files and images from your browser cache.
  2. If you loaded custom-elements-es5-adapter.js, remove it.
  3. Then use $ polymer serve --compile never.

According to this post, this issue is cause because $ polymer serve compiles your code to es5 automatically. The --compile never flag stops $ polymer serve from doing this.

like image 161
KingBryan Avatar answered Sep 27 '22 22:09

KingBryan


I had a similar Error the other day after moving my Polymer App to v.2.
This helped me:

To work around this, load custom-elements-es5-adapter.js before declaring new Custom Elements.

Since most projects need to support a wide range of browsers that don't necessary support ES6, it may make sense to compile your project to ES5. However, ES5-style custom element classes will not work with native Custom Elements because ES5-style classes cannot properly extend ES6 classes, like HTMLElement.

like image 36
Niklas Avatar answered Sep 27 '22 22:09

Niklas