babel-plugin-autobind-class-methods
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -13,2 +13,9 @@ "use strict"; | ||
ClassExpression: function ClassExpression(path, state) { | ||
var findBareSupers = { | ||
Super: function Super(path) { | ||
if (path.parentPath.isCallExpression({ callee: path.node })) { | ||
this.push(path.parentPath); | ||
} | ||
} | ||
}; | ||
var isDerived = !!path.node.superClass; | ||
@@ -72,5 +79,40 @@ var constructor = void 0; | ||
newNodes.forEach(function (node) { | ||
constructor.node.body.body.push(node); | ||
}); | ||
if (isDerived) { | ||
var bareSupers = []; | ||
constructor.traverse(findBareSupers, bareSupers); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
var _loop = function _loop() { | ||
var bareSuper = _step2.value; | ||
newNodes.forEach(function (node) { | ||
bareSuper.insertAfter(node); | ||
}); | ||
}; | ||
for (var _iterator2 = bareSupers[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
_loop(); | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} else { | ||
newNodes.forEach(function (node) { | ||
constructor.get("body").unshiftContainer("body", node); | ||
}); | ||
} | ||
} | ||
@@ -77,0 +119,0 @@ } |
{ | ||
"name": "babel-plugin-autobind-class-methods", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Babel plugin that binds every class method to \"this\" with hot reload support", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
106
7132
6