diff --git a/packages/svelte2tsx/src/htmlxtojsx/utils/node-utils.ts b/packages/svelte2tsx/src/htmlxtojsx/utils/node-utils.ts index 26751ab3e..bc9303a7f 100644 --- a/packages/svelte2tsx/src/htmlxtojsx/utils/node-utils.ts +++ b/packages/svelte2tsx/src/htmlxtojsx/utils/node-utils.ts @@ -129,7 +129,9 @@ function getNameValuePairsFromAttributes( return { name, value: valueStr, identifier: valueStr }; } if (val.expression.type === 'Literal') { - return { name, value: val.expression.value }; + const value = + typeof val.expression.value === 'string' ? '""' : val.expression.value; + return { name, value }; } return { name, value: valueStr, complexExpression: true }; } diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expected.jsx b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expected.jsx index 42d72d9ff..78ecaf646 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expected.jsx +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/expected.jsx @@ -1,5 +1,5 @@ -<>{() => {/*Ωignore_startΩ*/const Ψcomplex={a},Ψa_dashed_complex={a};/*Ωignore_endΩ*/() => { let {foo} = /*Ωignore_startΩ*/new Parent({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'complex':Ψcomplex, 'a-dashed-complex':Ψa_dashed_complex}})/*Ωignore_endΩ*/.$$slot_def['default'];<> - {() => { let {bar} = /*Ωignore_startΩ*/new Parent({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'complex':Ψcomplex, 'a-dashed-complex':Ψa_dashed_complex}})/*Ωignore_endΩ*/.$$slot_def['named'];<> +<>{() => {/*Ωignore_startΩ*/const Ψcomplex={a},Ψa_dashed_complex={a};/*Ωignore_endΩ*/() => { let {foo} = /*Ωignore_startΩ*/new Parent({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'strLiteral':"", 'complex':Ψcomplex, 'a-dashed-complex':Ψa_dashed_complex}})/*Ωignore_endΩ*/.$$slot_def['default'];<> + {() => { let {bar} = /*Ωignore_startΩ*/new Parent({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'strLiteral':"", 'complex':Ψcomplex, 'a-dashed-complex':Ψa_dashed_complex}})/*Ωignore_endΩ*/.$$slot_def['named'];<> {foo} {bar} }}
diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/input.svelte index 310d50fd8..bd71e0b3e 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/input.svelte +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/component-slot-infer-props/input.svelte @@ -1,4 +1,4 @@ - + {foo} {bar} diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expected.jsx b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expected.jsx index 18f05d970..f66f68b72 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expected.jsx +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/expected.jsx @@ -1 +1 @@ -<>{/*Ωignore_startΩ*/new Component({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'complex':{a}, 'a-dashed-complex':{a}}})/*Ωignore_endΩ*/.$on('click', e => e)} \ No newline at end of file +<>{/*Ωignore_startΩ*/new Component({target: __sveltets_any(''), props: {'bare':true, 'shorthand':shorthand, 'text1':"", 'text2':"", 'text3':"", 'textEmpty':"", 'literal':true, 'strLiteral':"", 'complex':{a}, 'a-dashed-complex':{a}}})/*Ωignore_endΩ*/.$on('click', e => e)} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/input.svelte index e666ae094..5ddbd664e 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/input.svelte +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/event-handler-component-infer-props/input.svelte @@ -1 +1 @@ - e} /> \ No newline at end of file + e} /> \ No newline at end of file