fix: inline style value become undefined (#8517)

fixes #8462

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
pull/8536/head
xxkl1 2 years ago committed by GitHub
parent 6bbae502f6
commit 32153e318d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -641,7 +641,7 @@ export function set_input_type(input, type) {
} }
export function set_style(node, key, value, important) { export function set_style(node, key, value, important) {
if (value === null) { if (value == null) {
node.style.removeProperty(key); node.style.removeProperty(key);
} else { } else {
node.style.setProperty(key, value, important ? 'important' : ''); node.style.setProperty(key, value, important ? 'important' : '');

@ -0,0 +1,11 @@
export default {
async test({ assert, target, window }) {
const div = target.querySelector('div');
const click = new window.MouseEvent('click');
assert.htmlEqual(target.innerHTML, '<div style="background: red;"></div>');
await div.dispatchEvent(click);
await Promise.resolve();
assert.htmlEqual(target.innerHTML, '<div style=""></div>');
}
};

@ -0,0 +1,9 @@
<script>
let bg = "red";
const handle = () => {
bg = undefined;
};
</script>
<div style:background={bg} on:click={handle}></div>
Loading…
Cancel
Save