Skip to content

Commit 7e3f875

Browse files
committed
Ignore <! when tokenizing JSX
Fixes #41
1 parent d670fd4 commit 7e3f875

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ module.exports = function(acorn) {
411411
return this.jsx_readString(code);
412412
}
413413

414-
if (code === 60 && this.exprAllowed) {
414+
if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
415415
++this.pos;
416416
return this.finishToken(tt.jsxTagStart);
417417
}

test/tests-jsx.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,6 +3787,16 @@ test('<a>{/* foo */}</a>', {}, {
37873787
]
37883788
});
37893789

3790+
test('<!--a', {
3791+
type: 'Program',
3792+
body: []
3793+
}, {
3794+
onComment: [{
3795+
type: 'Line',
3796+
value: 'a'
3797+
}]
3798+
});
3799+
37903800
for (var ns in fbTestFixture) {
37913801
ns = fbTestFixture[ns];
37923802
for (var code in ns) {

0 commit comments

Comments
 (0)