Giter Club home page Giter Club logo

Comments (3)

sdegutis avatar sdegutis commented on August 11, 2024

Looking at the generated tokens,

<span foo:hi='bar'></span>

produces

Location  Label       Raw   contextualKeyword scopeDepth isType identifierRole jsxRole shadowsGlobal isAsyncOperation contextId rhsEndIndex isExpression numNullishCoalesceStarts numNullishCoalesceEnds isOptionalChainStart isOptionalChainEnd subscriptStartIndex nullishStartIndex
1:1-1:2   jsxTagStart <     0                 0                                0                                                                         0                        0                                                                                                   
1:2-1:6   jsxName     span  0                 0                                                                                                          0                        0                                                                                                   
1:7-1:10  jsxName     foo   0                 0                                                                                                          0                        0                                                                                                   
1:10-1:11 :           :     0                 0                                                                                                          0                        0                                                                                                   
1:11-1:13 name        hi    0                 0                                                                                                          0                        0                                                                                                   
1:13-1:14 =           =     0                 0                                                                                                          0                        0                                                                                                   
1:14-1:19 string      'bar' 0                 0                                                                                                          0                        0                                                                                                   
1:19-1:20 jsxTagEnd   >     0                 0                                                                                                          0                        0                                                                                                   
1:20-1:21 jsxTagStart <     0                 0                                                                                                          0                        0                                                                                                   
1:21-1:22 /           /     0                 0                                                                                                          0                        0                                                                                                   
1:22-1:26 jsxName     span  0                 0                                                                                                          0                        0                                                                                                   
1:26-1:27 jsxTagEnd   >     0                 0                                                                                                          0                        0                                                                                                   
2:1-2:1   eof               0                 0                                                                                                          0                        0                                                                                                   

So a quick fix would just be to run through tokens, and when you find jsxName followed by : and name, combine those two into the jsxName value, and remove those two tokens.

from sucrase.

sdegutis avatar sdegutis commented on August 11, 2024

So far, this needs JSXTransformer.ts to have this inserted at line 420:

      } else if (this.tokens.matches4(tt.jsxName, tt.colon, tt.name, tt.eq)) {

Still not sure what to put in there though. I tried adding the two strings, and the linter said string concatenation is bad, so...

from sucrase.

sdegutis avatar sdegutis commented on August 11, 2024

Actually the tokenizer would probably be a better place.

from sucrase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.