[Pkg-javascript-commits] [node-acorn-jsx] 475/484: Ignore <! when tokenizing JSX

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:21:12 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit 7e3f8750d6ee99ec3bfa82991715566cafac674e
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Wed May 17 23:56:49 2017 +0100

    Ignore <! when tokenizing JSX
    
    Fixes #41
---
 inject.js         |  2 +-
 test/tests-jsx.js | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/inject.js b/inject.js
index d112032..042c24c 100644
--- a/inject.js
+++ b/inject.js
@@ -411,7 +411,7 @@ module.exports = function(acorn) {
             return this.jsx_readString(code);
         }
 
-        if (code === 60 && this.exprAllowed) {
+        if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
           ++this.pos;
           return this.finishToken(tt.jsxTagStart);
         }
diff --git a/test/tests-jsx.js b/test/tests-jsx.js
index 8537c6e..e35f6ac 100644
--- a/test/tests-jsx.js
+++ b/test/tests-jsx.js
@@ -3787,6 +3787,16 @@ test('<a>{/* foo */}</a>', {}, {
   ]
 });
 
+test('<!--a', {
+  type: 'Program',
+  body: []
+}, {
+  onComment: [{
+    type: 'Line',
+    value: 'a'
+  }]
+});
+
 for (var ns in fbTestFixture) {
   ns = fbTestFixture[ns];
   for (var code in ns) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list