@@ -252,25 +252,26 @@ function convertHTMLElement(
252252 ...locs ,
253253 } ;
254254 element . startTag . parent = element ;
255+ const elementName = node . name ;
255256
256257 const { letDirectives, attributes } = extractLetDirectives ( node ) ;
257258 const letParams : ScriptLetBlockParam [ ] = [ ] ;
258259 if ( letDirectives . length ) {
259260 ctx . letDirCollections . beginExtract ( ) ;
260261 element . startTag . attributes . push (
261- ...convertAttributes ( letDirectives , element . startTag , ctx )
262+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
262263 ) ;
263264 letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
264265 }
265266 if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
266267 element . startTag . attributes . push (
267- ...convertAttributes ( attributes , element . startTag , ctx )
268+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
268269 ) ;
269270 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
270271 } else {
271272 ctx . scriptLet . nestBlock ( element , letParams ) ;
272273 element . startTag . attributes . push (
273- ...convertAttributes ( attributes , element . startTag , ctx )
274+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
274275 ) ;
275276 sortNodes ( element . startTag . attributes ) ;
276277 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -282,7 +283,7 @@ function convertHTMLElement(
282283 ctx . addToken ( "HTMLIdentifier" , openTokenRange ) ;
283284 const name : SvelteName = {
284285 type : "SvelteName" ,
285- name : node . name ,
286+ name : elementName ,
286287 parent : element ,
287288 ...ctx . getConvertLocation ( openTokenRange ) ,
288289 } ;
@@ -359,25 +360,26 @@ function convertSpecialElement(
359360 ...locs ,
360361 } ;
361362 element . startTag . parent = element ;
363+ const elementName = node . name ;
362364
363365 const { letDirectives, attributes } = extractLetDirectives ( node ) ;
364366 const letParams : ScriptLetBlockParam [ ] = [ ] ;
365367 if ( letDirectives . length ) {
366368 ctx . letDirCollections . beginExtract ( ) ;
367369 element . startTag . attributes . push (
368- ...convertAttributes ( letDirectives , element . startTag , ctx )
370+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
369371 ) ;
370372 letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
371373 }
372374 if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
373375 element . startTag . attributes . push (
374- ...convertAttributes ( attributes , element . startTag , ctx )
376+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
375377 ) ;
376378 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
377379 } else {
378380 ctx . scriptLet . nestBlock ( element , letParams ) ;
379381 element . startTag . attributes . push (
380- ...convertAttributes ( attributes , element . startTag , ctx )
382+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
381383 ) ;
382384 sortNodes ( element . startTag . attributes ) ;
383385 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -386,9 +388,9 @@ function convertSpecialElement(
386388
387389 const thisExpression =
388390 ( node . type === "InlineComponent" &&
389- node . name === "svelte:component" &&
391+ elementName === "svelte:component" &&
390392 node . expression ) ||
391- ( node . type === "Element" && node . name === "svelte:element" && node . tag ) ;
393+ ( node . type === "Element" && elementName === "svelte:element" && node . tag ) ;
392394 if ( thisExpression ) {
393395 const eqIndex = ctx . code . lastIndexOf ( "=" , getWithLoc ( thisExpression ) . start ) ;
394396 const startIndex = ctx . code . lastIndexOf ( "this" , eqIndex ) ;
@@ -434,7 +436,7 @@ function convertSpecialElement(
434436 ctx . addToken ( "HTMLIdentifier" , openTokenRange ) ;
435437 const name : SvelteName = {
436438 type : "SvelteName" ,
437- name : node . name ,
439+ name : elementName ,
438440 parent : element ,
439441 ...ctx . getConvertLocation ( openTokenRange ) ,
440442 } ;
@@ -476,25 +478,26 @@ function convertComponentElement(
476478 ...locs ,
477479 } ;
478480 element . startTag . parent = element ;
481+ const elementName = node . name ;
479482
480483 const { letDirectives, attributes } = extractLetDirectives ( node ) ;
481484 const letParams : ScriptLetBlockParam [ ] = [ ] ;
482485 if ( letDirectives . length ) {
483486 ctx . letDirCollections . beginExtract ( ) ;
484487 element . startTag . attributes . push (
485- ...convertAttributes ( letDirectives , element . startTag , ctx )
488+ ...convertAttributes ( letDirectives , element . startTag , elementName , ctx )
486489 ) ;
487490 letParams . push ( ...ctx . letDirCollections . extract ( ) . getLetParams ( ) ) ;
488491 }
489492 if ( ! letParams . length && ! needScopeByChildren ( node ) ) {
490493 element . startTag . attributes . push (
491- ...convertAttributes ( attributes , element . startTag , ctx )
494+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
492495 ) ;
493496 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
494497 } else {
495498 ctx . scriptLet . nestBlock ( element , letParams ) ;
496499 element . startTag . attributes . push (
497- ...convertAttributes ( attributes , element . startTag , ctx )
500+ ...convertAttributes ( attributes , element . startTag , elementName , ctx )
498501 ) ;
499502 sortNodes ( element . startTag . attributes ) ;
500503 element . children . push ( ...convertChildren ( node , element , ctx ) ) ;
@@ -503,7 +506,7 @@ function convertComponentElement(
503506
504507 extractElementTags ( element , ctx , {
505508 buildNameNode : ( openTokenRange ) => {
506- const chains = node . name . split ( "." ) ;
509+ const chains = elementName . split ( "." ) ;
507510 const id = chains . shift ( ) ! ;
508511 const idRange = {
509512 start : openTokenRange . start ,
0 commit comments