check if shadow is defined before looking it up - fixes #2152

This commit is contained in:
Sebastian McKenzie 2015-08-04 13:03:14 +01:00
parent ee2e8d10ce
commit 4a17c07668

View File

@ -183,7 +183,7 @@ export function inType() {
export function inShadow(key?) {
var path = this;
while (path) {
do {
if (path.isFunction()) {
var shadow = path.node.shadow;
if (shadow || path.isArrowFunctionExpression()) {
@ -192,7 +192,7 @@ export function inShadow(key?) {
// { this: false }
//
// we need to catch this case if `inShadow` has been passed a `key`
if (!key || shadow[key] !== false) {
if (!key || !shadow || shadow[key] !== false) {
return path;
}
}
@ -200,7 +200,6 @@ export function inShadow(key?) {
// normal function, we've found our function context
return null;
}
path = path.parentPath;
}
} while(path = path.parentPath);
return null;
}