File tree Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Expand file tree Collapse file tree 2 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -304,9 +304,6 @@ function tokenize(code, options) {
304304 * @param {string } token_
305305 */
306306 const append = ( type_ , token_ ) => {
307- if ( type_ || token_ ) {
308- const nType = TokenTypes [ type_ ]
309- }
310307 if ( token_ ) {
311308 current = token_
312309 }
@@ -460,26 +457,26 @@ function tokenize(code, options) {
460457 if ( next === '-' && ! inStringContent ( ) && ! inJsxLiterals ( ) ) {
461458 if ( current ) {
462459 append ( T_PROPERTY , current + curr + next )
463- i += 1
460+ i ++
464461 continue
465462 }
466463 }
467464 // `=` in property=<value>
468465 if ( next === '=' && ! inStringContent ( ) ) {
469466 // if current is not a space, ensure `prop` is a property
470- if ( isSpaces ( current ) ) {
471- append ( T_SPACE , current )
472- current = ''
467+ if ( ! isSpaces ( curr ) ) {
468+ // If there're leading spaces, append them first
469+ if ( isSpaces ( current ) ) {
470+ append ( )
471+ }
472+
473+ // Now check if the accumulated token is a property
474+ const prop = current + curr
475+ if ( isIdentifier ( prop ) ) {
476+ append ( T_PROPERTY , prop )
477+ continue
478+ }
473479 }
474- const prop = current ? ( current + curr ) : curr
475- if ( isIdentifier ( prop ) ) {
476- current = prop
477- append ( T_PROPERTY )
478- } else if ( prop === ' ' ) {
479- current = prop
480- append ( T_SPACE )
481- }
482- continue
483480 }
484481 }
485482 }
Original file line number Diff line number Diff line change @@ -385,6 +385,7 @@ describe('jsx', () => {
385385 "( => sign",
386386 "v => identifier",
387387 ") => sign",
388+ " => space",
388389 "= => sign",
389390 "> => sign",
390391 " => space",
You can’t perform that action at this time.
0 commit comments