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.Static && $$props.static) &&
features & Features.RenderStrategy && features & Features.RenderStrategy &&
!unmount; !unmount;
$: propsWeControl = {
class: computedClass,
style:
`${computedStyle ?? ""}${hidden ? " display: none" : ""}` || undefined,
};
$: if (propsWeControl.style === undefined) {
delete propsWeControl.style;
}
</script> </script>
{#if show} {#if show}
@@ -87,9 +96,7 @@
bind:el bind:el
use={[...use, forwardEvents]} use={[...use, forwardEvents]}
{...$$restProps} {...$$restProps}
class={computedClass} {...propsWeControl}
style={`${computedStyle ?? ""}${hidden ? " display: none" : ""}` ||
undefined}
hidden={hidden || undefined} hidden={hidden || undefined}
> >
<slot /> <slot />