@@ -252,25 +252,26 @@ function convertHTMLElement(
252
252
...locs ,
253
253
} ;
254
254
element . startTag . parent = element ;
255
+ const elementName = node . name ;
255
256
256
257
const { letDirectives, attributes } = extractLetDirectives ( node ) ;
257
258
const letParams : ScriptLetBlockParam [ ] = [ ] ;
258
259
if ( letDirectives . length ) {
259
260
ctx . letDirCollections . beginExtract ( ) ;
260
261
element . startTag . attributes . push (
261
- ...convertAttributes ( letDirectives , element . startTag , ctx )
262
+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
262
263
) ;
263
264
letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
264
265
}
265
266
if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
266
267
element . startTag . attributes . push (
267
- ...convertAttributes ( attributes , element . startTag , ctx )
268
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
268
269
) ;
269
270
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
270
271
} else {
271
272
ctx . scriptLet . nestBlock ( element , letParams ) ;
272
273
element . startTag . attributes . push (
273
- ...convertAttributes ( attributes , element . startTag , ctx )
274
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
274
275
) ;
275
276
sortNodes ( element . startTag . attributes ) ;
276
277
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -282,7 +283,7 @@ function convertHTMLElement(
282
283
ctx . addToken ( "HTMLIdentifier" , openTokenRange ) ;
283
284
const name : SvelteName = {
284
285
type : "SvelteName" ,
285
- name : node . name ,
286
+ name : elementName ,
286
287
parent : element ,
287
288
...ctx . getConvertLocation ( openTokenRange ) ,
288
289
} ;
@@ -359,25 +360,26 @@ function convertSpecialElement(
359
360
...locs ,
360
361
} ;
361
362
element . startTag . parent = element ;
363
+ const elementName = node . name ;
362
364
363
365
const { letDirectives, attributes } = extractLetDirectives ( node ) ;
364
366
const letParams : ScriptLetBlockParam [ ] = [ ] ;
365
367
if ( letDirectives . length ) {
366
368
ctx . letDirCollections . beginExtract ( ) ;
367
369
element . startTag . attributes . push (
368
- ...convertAttributes ( letDirectives , element . startTag , ctx )
370
+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
369
371
) ;
370
372
letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
371
373
}
372
374
if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
373
375
element . startTag . attributes . push (
374
- ...convertAttributes ( attributes , element . startTag , ctx )
376
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
375
377
) ;
376
378
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
377
379
} else {
378
380
ctx . scriptLet . nestBlock ( element , letParams ) ;
379
381
element . startTag . attributes . push (
380
- ...convertAttributes ( attributes , element . startTag , ctx )
382
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
381
383
) ;
382
384
sortNodes ( element . startTag . attributes ) ;
383
385
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -386,9 +388,9 @@ function convertSpecialElement(
386
388
387
389
const thisExpression =
388
390
( node . type === "InlineComponent" &&
389
- node . name === "svelte:component" &&
391
+ elementName === "svelte:component" &&
390
392
node . expression ) ||
391
- ( node . type === "Element" && node . name === "svelte:element" && node . tag ) ;
393
+ ( node . type === "Element" && elementName === "svelte:element" && node . tag ) ;
392
394
if ( thisExpression ) {
393
395
const eqIndex = ctx . code . lastIndexOf ( "=" , getWithLoc ( thisExpression ) . start ) ;
394
396
const startIndex = ctx . code . lastIndexOf ( "this" , eqIndex ) ;
@@ -434,7 +436,7 @@ function convertSpecialElement(
434
436
ctx . addToken ( "HTMLIdentifier" , openTokenRange ) ;
435
437
const name : SvelteName = {
436
438
type : "SvelteName" ,
437
- name : node . name ,
439
+ name : elementName ,
438
440
parent : element ,
439
441
...ctx . getConvertLocation ( openTokenRange ) ,
440
442
} ;
@@ -476,25 +478,26 @@ function convertComponentElement(
476
478
...locs ,
477
479
} ;
478
480
element . startTag . parent = element ;
481
+ const elementName = node . name ;
479
482
480
483
const { letDirectives, attributes } = extractLetDirectives ( node ) ;
481
484
const letParams : ScriptLetBlockParam [ ] = [ ] ;
482
485
if ( letDirectives . length ) {
483
486
ctx . letDirCollections . beginExtract ( ) ;
484
487
element . startTag . attributes . push (
485
- ...convertAttributes ( letDirectives , element . startTag , ctx )
488
+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
486
489
) ;
487
490
letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
488
491
}
489
492
if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
490
493
element . startTag . attributes . push (
491
- ...convertAttributes ( attributes , element . startTag , ctx )
494
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
492
495
) ;
493
496
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
494
497
} else {
495
498
ctx . scriptLet . nestBlock ( element , letParams ) ;
496
499
element . startTag . attributes . push (
497
- ...convertAttributes ( attributes , element . startTag , ctx )
500
+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
498
501
) ;
499
502
sortNodes ( element . startTag . attributes ) ;
500
503
element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -503,7 +506,7 @@ function convertComponentElement(
503
506
504
507
extractElementTags ( element , ctx , {
505
508
buildNameNode : ( openTokenRange ) => {
506
- const chains = node . name . split ( "." ) ;
509
+ const chains = elementName . split ( "." ) ;
507
510
const id = chains . shift ( ) ! ;
508
511
const idRange = {
509
512
start : openTokenRange . start ,
0 commit comments