Fix several edge cases with context expression state (#8972)

* Fix several edge cases with context expression state

* Fix review comments

* Remove unused field
This commit is contained in:
Daniel Tschinder
2018-11-06 19:37:24 -08:00
committed by GitHub
parent afe67a7035
commit 5d5cd8612f
21 changed files with 1986 additions and 37 deletions

View File

@@ -506,6 +506,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.parseLiteral(this.state.value, "JSXText");
} else if (this.match(tt.jsxTagStart)) {
return this.jsxParseElement();
} else if (
this.isRelational("<") &&
this.state.input.charCodeAt(this.state.pos) !==
charCodes.exclamationMark
) {
// In case we encounter an lt token here it will always be the start of
// jsx as the lt sign is not allowed in places that expect an expression
this.finishToken(tt.jsxTagStart);
return this.jsxParseElement();
} else {
return super.parseExprAtom(refShortHandDefaultPos);
}
@@ -538,7 +547,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
}
}
if (code === charCodes.lessThan && this.state.exprAllowed) {
if (
code === charCodes.lessThan &&
this.state.exprAllowed &&
this.state.input.charCodeAt(this.state.pos + 1) !==
charCodes.exclamationMark
) {
++this.state.pos;
return this.finishToken(tt.jsxTagStart);
}