@@ -3,6 +3,7 @@ import svelte from 'svelte/compiler';
33import { Node } from 'estree-walker' ;
44import { parseHtmlx } from './htmlxparser' ;
55import svgAttributes from './svgattributes' ;
6+ import { getTypeForComponent } from './nodes/component-type' ;
67
78type ElementType = string ;
89const oneWayBindingAttributes : Map < string , ElementType > = new Map (
@@ -73,7 +74,7 @@ export function convertHtmlxToJsx(
7374 const on = 'on' ;
7475 //for handler assignment, we changeIt to call to our __sveltets_ensureFunction
7576 str . appendRight (
76- attr . start , `{__sveltets_instanceOf(${ parent . name } ).$`
77+ attr . start , `{__sveltets_instanceOf(${ getTypeForComponent ( parent ) } ).$`
7778 ) ;
7879 const eventNameIndex = htmlx . indexOf ( ':' , attr . start ) + 1 ;
7980 str . overwrite (
@@ -172,17 +173,11 @@ export function convertHtmlxToJsx(
172173 } ;
173174
174175 const handleBinding = ( attr : Node , el : Node ) => {
175- const getThisTypeForComponent = ( node : Node ) => {
176- if ( node . name === 'svelte:component' || node . name === 'svelte:self' ) {
177- return '__sveltets_componentType()' ;
178- } else {
179- return node . name ;
180- }
181- } ;
176+
182177 const getThisType = ( node : Node ) => {
183178 switch ( node . type ) {
184179 case 'InlineComponent' :
185- return getThisTypeForComponent ( node ) ;
180+ return getTypeForComponent ( node ) ;
186181 case 'Element' :
187182 return 'HTMLElement' ;
188183 case 'Body' :
@@ -229,7 +224,7 @@ export function convertHtmlxToJsx(
229224 str . appendLeft (
230225 attr . end ,
231226 `=__sveltets_instanceOf(${ oneWayBindingAttributes . get ( attr . name ) } ).${
232- attr . name
227+ attr . name
233228 } )}`,
234229 ) ;
235230 } else {
@@ -238,7 +233,7 @@ export function convertHtmlxToJsx(
238233 attr . expression . end ,
239234 attr . end ,
240235 `=__sveltets_instanceOf(${ oneWayBindingAttributes . get ( attr . name ) } ).${
241- attr . name
236+ attr . name
242237 } )}`,
243238 ) ;
244239 }
0 commit comments