From 23c20cc47c82e4e1446d72a9d9a1d6e9fa301081 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 26 Mar 2015 01:02:47 +1100 Subject: [PATCH] inherit from the user constructor properly --- src/babel/transformation/transformers/es6/classes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/babel/transformation/transformers/es6/classes.js b/src/babel/transformation/transformers/es6/classes.js index 54e82e8f01..797f3bcf6b 100644 --- a/src/babel/transformation/transformers/es6/classes.js +++ b/src/babel/transformation/transformers/es6/classes.js @@ -295,6 +295,8 @@ class ClassTransformer { // if (this.userConstructor) { constructorBody.body = constructorBody.body.concat(this.userConstructor.body.body); + t.inherits(this.constructor, this.userConstructor); + t.inherits(this.constructorBody, this.userConstructor.body); } var instanceProps; @@ -360,7 +362,7 @@ class ClassTransformer { if (body.length) { // todo: check for scope conflicts and shift into a method if (this.hasSuper) { - if (this.bareSuper) { + if (this.hasConstructor) { this.bareSuper.insertAfter(body); } else { this.constructorBody.body = this.constructorBody.body.concat(body); @@ -469,7 +471,6 @@ class ClassTransformer { this.userConstructor = fn; this.hasConstructor = true; - t.inherits(construct, fn); t.inheritsComments(construct, method); construct._ignoreUserWhitespace = true;