@@ -82,7 +82,11 @@ export function* convertChildren(
8282 continue
8383 }
8484 if ( child . type === "Element" ) {
85- yield convertHTMLElement ( child , parent , ctx )
85+ if ( child . name . includes ( ":" ) ) {
86+ yield convertSpecialElement ( child , parent , ctx )
87+ } else {
88+ yield convertHTMLElement ( child , parent , ctx )
89+ }
8690 continue
8791 }
8892 if ( child . type === "InlineComponent" ) {
@@ -277,6 +281,7 @@ function convertHTMLElement(
277281function convertSpecialElement (
278282 node :
279283 | SvAST . InlineComponent
284+ | SvAST . Element
280285 | SvAST . Window
281286 | SvAST . Body
282287 | SvAST . Head
@@ -330,20 +335,18 @@ function convertSpecialElement(
330335 ctx . scriptLet . closeScope ( )
331336 }
332337
333- if (
334- node . type === "InlineComponent" &&
335- node . expression &&
336- node . name === "svelte:component"
337- ) {
338+ const thisExpression =
339+ ( node . type === "InlineComponent" &&
340+ node . name === "svelte:component" &&
341+ node . expression ) ||
342+ ( node . type === "Element" && node . name === "svelte:element" && node . tag )
343+ if ( thisExpression ) {
338344 const eqIndex = ctx . code . lastIndexOf (
339345 "=" ,
340- getWithLoc ( node . expression ) . start ,
346+ getWithLoc ( thisExpression ) . start ,
341347 )
342348 const startIndex = ctx . code . lastIndexOf ( "this" , eqIndex )
343- const closeIndex = ctx . code . indexOf (
344- "}" ,
345- getWithLoc ( node . expression ) . end ,
346- )
349+ const closeIndex = ctx . code . indexOf ( "}" , getWithLoc ( thisExpression ) . end )
347350 const endIndex = indexOf (
348351 ctx . code ,
349352 ( c ) => c === ">" || ! c . trim ( ) ,
@@ -366,7 +369,7 @@ function convertSpecialElement(
366369 start : startIndex ,
367370 end : eqIndex ,
368371 } )
369- ctx . scriptLet . addExpression ( node . expression , thisAttr , null , ( es ) => {
372+ ctx . scriptLet . addExpression ( thisExpression , thisAttr , null , ( es ) => {
370373 thisAttr . expression = es
371374 } )
372375 element . startTag . attributes . push ( thisAttr )
0 commit comments