google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.17k stars 580 forks source link

Failed to construct classes with 'HTMLElement' as super #2148

Open duzy opened 3 years ago

duzy commented 3 years ago

Traceur transpiled code is looking like this:

var e,r=customElements,n=(e=HTMLElement,$traceurRuntime.createClass((function e(){$traceurRuntime.superConstructor(e).call(this),this.style="color: red;"}),{},{},e));

From:

class Foo extends HTMLElement {
  constructor() { super();
    this.style = 'color: red;';
  }
};

And results:

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

Where this statement fails (the this object is a HTMLElement instance):

$traceurRuntime.superConstructor(e).call(this)