File tree Expand file tree Collapse file tree 2 files changed +160
-1
lines changed Expand file tree Collapse file tree 2 files changed +160
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,9 @@ module.exports = function(acorn) {
168
168
// Transforms JSX element name to string.
169
169
170
170
function getQualifiedJSXName ( object ) {
171
+ if ( ! object )
172
+ return object ;
173
+
171
174
if ( object . type === 'JSXIdentifier' )
172
175
return object . name ;
173
176
@@ -209,6 +212,8 @@ module.exports = function(acorn) {
209
212
// or single identifier.
210
213
211
214
pp . jsx_parseElementName = function ( ) {
215
+ if ( this . type === tt . jsxTagEnd )
216
+ return '' ;
212
217
var startPos = this . start , startLoc = this . startLoc ;
213
218
var node = this . jsx_parseNamespacedName ( ) ;
214
219
if ( this . type === tt . dot && node . type === 'JSXNamespacedName' && ! this . options . plugins . jsx . allowNamespacedObjects ) {
@@ -348,7 +353,7 @@ module.exports = function(acorn) {
348
353
if ( this . type === tt . relational && this . value === "<" ) {
349
354
this . raise ( this . start , "Adjacent JSX elements must be wrapped in an enclosing tag" ) ;
350
355
}
351
- return this . finishNode ( node , 'JSXElement' ) ;
356
+ return this . finishNode ( node , openingElement . name ? 'JSXElement' : 'JSXFragment ') ;
352
357
} ;
353
358
354
359
// Parse JSX text
Original file line number Diff line number Diff line change @@ -3183,6 +3183,160 @@ var fbTestFixture = {
3183
3183
}
3184
3184
]
3185
3185
}
3186
+ } ,
3187
+
3188
+ '<><div></div></>' : {
3189
+ type : 'ExpressionStatement' ,
3190
+ start : 0 ,
3191
+ end : 16 ,
3192
+ loc : {
3193
+ start : {
3194
+ line : 1 ,
3195
+ column : 0
3196
+ } ,
3197
+ end : {
3198
+ line : 1 ,
3199
+ column : 16
3200
+ }
3201
+ } ,
3202
+ range : [ 0 , 16 ] ,
3203
+ expression : {
3204
+ type : 'JSXFragment' ,
3205
+ start : 0 ,
3206
+ end : 16 ,
3207
+ loc : {
3208
+ start : {
3209
+ line : 1 ,
3210
+ column : 0
3211
+ } ,
3212
+ end : {
3213
+ line : 1 ,
3214
+ column : 16
3215
+ }
3216
+ } ,
3217
+ range : [ 0 , 16 ] ,
3218
+ openingElement : {
3219
+ type : 'JSXOpeningElement' ,
3220
+ start : 0 ,
3221
+ end : 2 ,
3222
+ loc : {
3223
+ start : {
3224
+ line : 1 ,
3225
+ column : 0
3226
+ } ,
3227
+ end : {
3228
+ line : 1 ,
3229
+ column : 2
3230
+ }
3231
+ } ,
3232
+ range : [ 0 , 2 ] ,
3233
+ attributes : [ ] ,
3234
+ name : '' ,
3235
+ selfClosing : false
3236
+ } ,
3237
+ closingElement : {
3238
+ type : 'JSXClosingElement' ,
3239
+ start : 13 ,
3240
+ end : 16 ,
3241
+ loc : {
3242
+ start : {
3243
+ line : 1 ,
3244
+ column : 13
3245
+ } ,
3246
+ end : {
3247
+ line : 1 ,
3248
+ column : 16
3249
+ }
3250
+ } ,
3251
+ range : [ 13 , 16 ] ,
3252
+ name : ''
3253
+ } ,
3254
+ children : [ {
3255
+ type : 'JSXElement' ,
3256
+ start : 2 ,
3257
+ end : 13 ,
3258
+ loc : {
3259
+ start : {
3260
+ line : 1 ,
3261
+ column : 2
3262
+ } ,
3263
+ end : {
3264
+ line : 1 ,
3265
+ column : 13
3266
+ }
3267
+ } ,
3268
+ range : [ 2 , 13 ] ,
3269
+ openingElement : {
3270
+ type : 'JSXOpeningElement' ,
3271
+ start : 2 ,
3272
+ end : 7 ,
3273
+ loc : {
3274
+ start : {
3275
+ line : 1 ,
3276
+ column : 2
3277
+ } ,
3278
+ end : {
3279
+ line : 1 ,
3280
+ column : 7
3281
+ }
3282
+ } ,
3283
+ range : [ 2 , 7 ] ,
3284
+ attributes : [ ] ,
3285
+ name : {
3286
+ type : 'JSXIdentifier' ,
3287
+ start : 3 ,
3288
+ end : 6 ,
3289
+ loc : {
3290
+ start : {
3291
+ line : 1 ,
3292
+ column : 3
3293
+ } ,
3294
+ end : {
3295
+ line : 1 ,
3296
+ column : 6
3297
+ }
3298
+ } ,
3299
+ range : [ 3 , 6 ] ,
3300
+ name : 'div'
3301
+ } ,
3302
+ selfClosing : false
3303
+ } ,
3304
+ closingElement : {
3305
+ type : 'JSXClosingElement' ,
3306
+ start : 7 ,
3307
+ end : 13 ,
3308
+ loc : {
3309
+ start : {
3310
+ line : 1 ,
3311
+ column : 7
3312
+ } ,
3313
+ end : {
3314
+ line : 1 ,
3315
+ column : 13
3316
+ }
3317
+ } ,
3318
+ range : [ 7 , 13 ] ,
3319
+ name : {
3320
+ type : 'JSXIdentifier' ,
3321
+ start : 9 ,
3322
+ end : 12 ,
3323
+ loc : {
3324
+ start : {
3325
+ line : 1 ,
3326
+ column : 9
3327
+ } ,
3328
+ end : {
3329
+ line : 1 ,
3330
+ column : 12
3331
+ }
3332
+ } ,
3333
+ range : [ 9 , 12 ] ,
3334
+ name : 'div'
3335
+ }
3336
+ } ,
3337
+ children : [ ]
3338
+ } ]
3339
+ }
3186
3340
}
3187
3341
} ,
3188
3342
'Regression' : {
You can’t perform that action at this time.
0 commit comments