super() not calling parent's constructor on IE9
See original GitHub issueHello,
After upgrading to babel@6.0.14, babelify@7.1.0 and babel-preset-es2015@ 6.0.14 it seems that on IE9, calling super() on a child class’ constructor doesn’t call the parent’s constructor anymore.
The two classes live on different files and I import/export the whole using the ES2015 module syntax.
Like so:
// in myClassA.js
export class A {
constructor() {
console.log('I am your father');
}
init() {
console.log('And I know who your sister is');
}
}
// in myClassB.js
import {A} from './myClassA.js';
export class B extends A {
constructor() {
// Won't do anything
super();
}
init() {
// Will fire A.init() properly: 'And I know who your sister is' is logged
super.init();
}
}
// Wherever else
import {B} from './myClassB';
window.onload = () => {
var B = new B();
}
And in my gulp task:
(...).transform(babel.configure({
presets: ["es2015"],
ignore: ["client/vendor"]
}));
It’s working well on IE >= 10 but unfortunately not on IE9. I’m opening the issue on the babelify repo since I’m using it but maybe it belongs to the babel one.
Reverting back to babel@5 and babelify@6 fixes the issue.
Thanks for the support and continue the good work guys !
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
In JavaScript, why super keyword is not calling always parent ...
super does always call the "parent" class methods. But your log "Message 2 from Child class" is caused by this.msg2() in the parent...
Read more >simpledeclare - npm
Easy calling of asyncronous super methods with this.inheritedAsync(); Automatic execution of all constructors in the right order; Automatic inheritance of ...
Read more >CoffeeScript
Identical to calling coffee with no arguments. ... Or if you know that the parent function doesn't require arguments, just call super() :....
Read more >Inheritance in JavaScript
Note that we've only specified this inside call() — no other ... To call the parent constructor we have to use the super()...
Read more >Finally Understanding the Advanced uses of "This" in Javascript
The above will call Whatever (or its constructor function if it's a ... if the function is called without its parent object, or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please, what’s the final word on this? It seems like
super
doesn’t work on <=IE10 except if usinges2015-loose
preset. Is that correct? Is that the suggested approach/workaround or is there a better solution that doesn’t make use of the loose mode (e.g., inclusion of a polyfill?)? Should http://babeljs.io/docs/plugins/transform-es2015-object-super/ include a list of supported browsers? Thank youIs this still an issue? I tried to run a few tests and I didn’t encounter any problems anymore on IE9. I used the es2015-loose preset without transform-proto-to-assign. My code is in here: https://jsfiddle.net/peternoordijk/ymtyud9y/