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)
This commit is contained in:
Ryan Gossiaux
2022-02-25 18:37:48 -08:00
parent 3c9dcc9b67
commit 87aadf2490

View File

@@ -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;
}
</script>
{#if show}
@@ -87,9 +96,7 @@
bind:el
use={[...use, forwardEvents]}
{...$$restProps}
class={computedClass}
style={`${computedStyle ?? ""}${hidden ? " display: none" : ""}` ||
undefined}
{...propsWeControl}
hidden={hidden || undefined}
>
<slot />