Skip to content

Commit

Permalink
fix(memberexpression): parse nested memberexpression
Browse files Browse the repository at this point in the history
fix #21
  • Loading branch information
thetutlage committed Jan 26, 2018
1 parent 9b9de87 commit 5aee3ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Expressions/MemberExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MemberExpression extends BaseExpression {
}

this._tokens.members.push({
value: this._lexer.parseStatement(member.property),
value: this._lexer.parse(member.property),
computed: member.computed
})
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/member-expression.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ test.group('Member Expression', (group) => {
this.exp.parse(esprima.parse(statement).body[0].expression)
assert.equal(this.exp.toStatement(), `this.context.accessChild(this.context.resolve('users'), [this.context.resolve('username'),'age'])`)
})

test('should be able to parse a nested computed expression', (assert) => {
const statement = `users[username.prop]`
this.exp.parse(esprima.parse(statement).body[0].expression)
assert.equal(this.exp.toStatement(), `this.context.accessChild(this.context.resolve('users'), [this.context.accessChild(this.context.resolve('username'), ['prop'])])`)
})
})

0 comments on commit 5aee3ba

Please sign in to comment.