Reputation: 222513
Here is simple plunker example involving class inheritance, with shims and Babel options being set to stage: 0, loose: 'all'
:
class Hello {
static address = ', world!';
greeting = 'Hello';
constructor() {
this.greet();
}
greet() {
document.write(this.greeting + Hello.address);
}
}
class Hi extends Hello {
greeting = 'Hi';
constructor() {
super();
}
}
new Hi().greet();
Apparently, it works as it should in IE5.5+.
What are the circumstances where Babel spec.protoToAssign
transformer can be beneficial (or undesirable) for ES6/ES7 transpiled OOP code that is targeted to legacy browsers?
Upvotes: 2
Views: 782
Reputation: 161467
ES6 class inheritance also means that
Hi.address
would work because Hi
inherits from Hello
. Without protoToAssign
, this will not work in IE<=10.
The general case is exactly as described on that page however. IE<=10 does not support assignment of __proto__
so if you rely on behavior that relied on it, it will not work.
This is all covered in the caveats page for Babel.
Upvotes: 2