From f83707adbc5941be5c02ec5b0e11fa501f24f15c Mon Sep 17 00:00:00 2001 From: xxkl1 Date: Wed, 19 Apr 2023 01:14:30 +0800 Subject: [PATCH] fix: style value not remove when become undefined --- src/runtime/internal/dom.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index c025313c15..00a38b5b1d 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -307,7 +307,7 @@ export function attr(node: Element, attribute: string, value?: string) { else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value); } -/** +/** * List of attributes that should always be set through the attr method, * because updating them through the property setter doesn't work reliably. * In the example of `width`/`height`, the problem is that the setter only @@ -641,7 +641,7 @@ export function set_input_type(input, type) { } export function set_style(node, key, value, important) { - if (value === null) { + if (value === null || value === undefined) { node.style.removeProperty(key); } else { node.style.setProperty(key, value, important ? 'important' : '');