Re-use central inShadow logic.

This commit is contained in:
Logan Smyth 2016-03-06 03:16:11 -08:00
parent 8b8e3ddbec
commit 836f398619
2 changed files with 5 additions and 8 deletions

View File

@ -20,11 +20,7 @@ function isMemberExpressionSuper(node) {
}
let visitor = {
"ObjectMethod|ClassMethod"(path) {
path.skip();
},
"FunctionDeclaration|FunctionExpression"(path) {
Function(path) {
if (!path.inShadow("this")) {
path.skip();
}

View File

@ -220,14 +220,15 @@ export function inShadow(key?) {
let parentFn = this.isFunction() ? this : this.findParent((p) => p.isFunction());
if (!parentFn) return;
let shadow = parentFn.node.shadow;
if (shadow) {
if (parentFn.isFunctionExpression() || parentFn.isFunctionDeclaration()) {
let shadow = parentFn.node.shadow;
// this is because sometimes we may have a `shadow` value of:
//
// { this: false }
//
// we need to catch this case if `inShadow` has been passed a `key`
if (!key || shadow[key] !== false) {
if (shadow && (!key || shadow[key] !== false)) {
return parentFn;
}
} else if (parentFn.isArrowFunctionExpression()) {