diff --git a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts index 12f3396ee..0ef4095cc 100644 --- a/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts +++ b/packages/svelte2tsx/src/htmlxtojsx_v2/nodes/Attribute.ts @@ -94,7 +94,7 @@ export function handleAttribute( element.addAttribute(name, value); } : (name: TransformationArray, value?: TransformationArray) => { - if (attr.name.startsWith('--') && attr.value !== true) { + if (attr.name.startsWith('--')) { // CSS custom properties are not part of the props // definition, so wrap them to not get "--xx is invalid prop" errors name.unshift('...__sveltets_2_cssProp({'); diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js index 1968d107d..481e683cc 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/expectedv2.js @@ -1 +1 @@ - { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":'hi'}),...__sveltets_2_cssProp({"--custom-css-property2":`hi`}),"betweenprop":true,...__sveltets_2_cssProp({"--custom-css-property3":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property5":`hi${jo}hi`}),}});} \ No newline at end of file + { const $$_tnenopmoC0C = __sveltets_2_ensureComponent(Component); new $$_tnenopmoC0C({ target: __sveltets_2_any(), props: { ...__sveltets_2_cssProp({"--custom-css-property1":'hi'}),...__sveltets_2_cssProp({"--custom-css-property2":`hi`}),"betweenprop":true,...__sveltets_2_cssProp({"--custom-css-property3":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property4":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property5":`hi${jo}hi`}),...__sveltets_2_cssProp({"--custom-css-property6":true}),}});} \ No newline at end of file diff --git a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/input.svelte b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/input.svelte index 22f7f271b..316a0d999 100644 --- a/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/input.svelte +++ b/packages/svelte2tsx/test/htmlx2jsx/samples/custom-css-properties/input.svelte @@ -4,4 +4,5 @@ betweenprop --custom-css-property3="hi{jo}hi" --custom-css-property4='hi{jo}hi' - --custom-css-property5=hi{jo}hi /> + --custom-css-property5=hi{jo}hi + --custom-css-property6 />