fix(parser): fix additional char being consumed in JSXText (#259)

This commit is contained in:
Wei Zhu 2023-04-06 15:52:04 +10:00 committed by GitHub
parent 6fca022982
commit b17181a0c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1128,10 +1128,17 @@ impl<'a> Lexer<'a> {
/// `JSXFragment`
/// { `JSXChildExpressionopt` }
fn read_jsx_child(&mut self) -> Kind {
match self.current.chars.next() {
Some('<') => Kind::LAngle,
Some('{') => Kind::LCurly,
Some(c) => {
match self.peek() {
'<' => {
self.current.chars.next();
Kind::LAngle
}
'{' => {
self.current.chars.next();
Kind::LCurly
}
EOF => Kind::Eof,
c => {
let mut builder = AutoCow::new(self);
builder.push_matching(c);
loop {
@ -1149,7 +1156,6 @@ impl<'a> Lexer<'a> {
self.current.token.value = self.string_to_token_value(builder.finish(self));
Kind::JSXText
}
None => Kind::Eof,
}
}