bublejs / buble

https://buble.surge.sh
MIT License
871 stars 67 forks source link

Unnecessary `__proto__` #211

Closed fengxinming closed 5 years ago

fengxinming commented 5 years ago
58          if (this.parent.superClass) {
59              let inheritanceBlock = `if ( ${superName} ) ${name}.__proto__ = ${
60                  superName
61              };\n${i0}${name}.prototype = Object.create( ${superName} && ${
62                  superName
63              }.prototype );\n${i0}${name}.prototype.constructor = ${name};`;
goto-bus-stop commented 5 years ago
if ( ${superName} ) ${name}.__proto__ = ${superName};

This makes inheritance of static members work, for code like this:

class A {
  static method() { return 1 }
}
class B extends A {}

B.method() == 1
fengxinming commented 5 years ago

@goto-bus-stop Great answer, thanks!