diff --git a/src/babel/traversal/path/introspection.js b/src/babel/traversal/path/introspection.js index 33875b1013..4495520e06 100644 --- a/src/babel/traversal/path/introspection.js +++ b/src/babel/traversal/path/introspection.js @@ -10,11 +10,10 @@ import * as t from "../../types"; */ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean { - var parts = pattern.split("."); - // not a member expression if (!this.isMemberExpression()) return false; + var parts = pattern.split("."); var search = [this.node]; var i = 0; @@ -41,10 +40,12 @@ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean // we can't deal with this return false; } else { - search.push(node.object); - search.push(node.property); + search.unshift(node.property); + search.unshift(node.object); continue; } + } else if (t.isThisExpression(node)) { + if (!matches("this")) return false; } else { // we can't deal with this return false; @@ -56,7 +57,7 @@ export function matchesPattern(pattern: string, allowPartial?: boolean): boolean } } - return true; + return i === parts.length; } /** diff --git a/test/core/util.js b/test/core/util.js index 4588f728fe..b4925d4fb6 100644 --- a/test/core/util.js +++ b/test/core/util.js @@ -95,6 +95,12 @@ suite("util", function () { }, /illegal type for regexify/); }); + test("booleanify", function () { + assert.strictEqual(util.booleanify("true"), true); + assert.strictEqual(util.booleanify("false"), false); + assert.strictEqual(util.booleanify("inline"), "inline"); + }); + test("toIdentifier", function () { assert.equal(t.toIdentifier(t.identifier("swag")), "swag"); assert.equal(t.toIdentifier("swag-lord"), "swagLord");