Skip to content

Commit

Permalink
JSX: Fix assignment expression parsing in place holders
Browse files Browse the repository at this point in the history
Fixes #2092
  • Loading branch information
arv committed Mar 23, 2016
1 parent 09a6914 commit c58237a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/syntax/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4409,7 +4409,7 @@ export class Parser {
case OPEN_CURLY: {
let start = token.location.start;
let expression = null;
if (peekJsxToken().type !== CLOSE_CURLY) {
if (!peek(CLOSE_CURLY)) {
expression = this.parseAssignmentExpression_(ALLOW_IN);
}
this.eatJsx_(CLOSE_CURLY);
Expand Down
30 changes: 30 additions & 0 deletions test/feature/JSX/ThisInPlaceHolder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Options: --jsx=f

let f = (tag, props, ...children) => {
return children;
};

class C {
m() {
return <a> x {this} y </a>;
}
n() {
return <a> x {} y </a>;
}
o() {
return <a> x {}{} y </a>;
}
p() {
return <a b={this}/>;
}
}

const c = new C();
assert.deepEqual([' x ', c, ' y '], c.m());
assert.deepEqual([' x ', ' y '], c.n());
assert.deepEqual([' x ', ' y '], c.o());

f = (tag, props, ...children) => {
return props;
};
assert.deepEqual({b: c}, c.p());

0 comments on commit c58237a

Please sign in to comment.