From 3253f5660281843ec922cb17908af31e77d0f032 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 10 Jul 2014 13:43:16 +0300 Subject: [PATCH] Fixed skipping spaces at the beginning of JSX contents. Conflicts: acorn.js --- acorn.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/acorn.js b/acorn.js index 87112da42d..7bed972444 100644 --- a/acorn.js +++ b/acorn.js @@ -544,7 +544,9 @@ tokEnd = tokPos; if (options.locations) tokEndLoc = new Position; tokType = type; - if (shouldSkipSpace !== false) skipSpace(); + if (shouldSkipSpace !== false && !(inXJSTag && val === '>')) { + skipSpace(); + } tokVal = val; tokRegexpAllowed = type.beforeExpr; if (options.onToken) { @@ -830,15 +832,15 @@ if (options.locations) tokStartLoc = new Position; if (forceRegexp) return readRegexp(); if (tokPos >= inputLen) return finishToken(_eof); - if (inXJSChild) { - readXJSText(['<', '{']); - if (tokEnd > tokStart) { - return; - } - } var code = input.charCodeAt(tokPos); + // JSX content - either simple text, start of or {expression} + if (inXJSChild && code !== 60 && code !== 123) { + return readXJSText(['<', '{']); + } + + if (inTemplate) return getTemplateToken(code); // Identifier or keyword. '\uXXXX' sequences are allowed in