fix: apply CSS custom properties with falsy values on components (#18634)

svelte0/svelte-15053-fix-stop-currenttime-binding-updates-during-outros
남정욱 2 weeks ago committed by GitHub
parent 135f4439c3
commit 7725f77cca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: apply CSS custom properties with falsy values on components

@ -18,10 +18,10 @@ export function css_props(element, get_styles) {
for (var key in styles) { for (var key in styles) {
var value = styles[key]; var value = styles[key];
if (value) { if (value == null || value === '') {
element.style.setProperty(key, value);
} else {
element.style.removeProperty(key); element.style.removeProperty(key);
} else {
element.style.setProperty(key, value);
} }
} }
}); });

@ -0,0 +1,12 @@
import { test } from '../../test';
export default test({
ssrHtml: `<svelte-css-wrapper style="display: contents; --zero: 0; --one: 1;"><div>Hello</div></svelte-css-wrapper>`,
async test({ assert, target }) {
assert.htmlEqual(
target.innerHTML,
`<svelte-css-wrapper style="display: contents; --zero: 0; --one: 1;"><div>Hello</div></svelte-css-wrapper>`
);
}
});

@ -0,0 +1,5 @@
<script>
import Component from './Component.svelte';
</script>
<Component --zero={0} --one={1} --empty={''} --nullish={null} />
Loading…
Cancel
Save