From 87aadf24908b3c7347e09f04dbcb77b369d88942 Mon Sep 17 00:00:00 2001 From: Ryan Gossiaux Date: Fri, 25 Feb 2022 18:37:48 -0800 Subject: [PATCH] Fix `style` attribute getting wiped away incorrectly This fixes an issue where any update to a component would un-set the `style` attribute, which interacts poorly with actions that use inline styles (like Popper) --- src/lib/utils/Render.svelte | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/utils/Render.svelte b/src/lib/utils/Render.svelte index 266d2cd..a436a4e 100644 --- a/src/lib/utils/Render.svelte +++ b/src/lib/utils/Render.svelte @@ -79,6 +79,15 @@ !(features & Features.Static && $$props.static) && features & Features.RenderStrategy && !unmount; + + $: propsWeControl = { + class: computedClass, + style: + `${computedStyle ?? ""}${hidden ? " display: none" : ""}` || undefined, + }; + $: if (propsWeControl.style === undefined) { + delete propsWeControl.style; + } {#if show} @@ -87,9 +96,7 @@ bind:el use={[...use, forwardEvents]} {...$$restProps} - class={computedClass} - style={`${computedStyle ?? ""}${hidden ? " display: none" : ""}` || - undefined} + {...propsWeControl} hidden={hidden || undefined} >