-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte: Fix decorators with slots #19987
Conversation
* Check if an object is a svelte component. | ||
* @param obj Object | ||
*/ | ||
function isSvelteComponent(obj: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work in dev mode with Vite (and maybe with Webpack) because the component is an instance of an empty ProxyComponent
instead.
I asked on the Svelte Discord for alternatives, but we haven't come up with any yet.
https://discord.com/channels/457912077277855764/1046174450749558895/1046174450749558895
} = storyFn(); | ||
|
||
// reactive, re-render on storyFn change | ||
$: ({ Component, props = {}, on, Wrapper, WrapperData = {} } = storyFn()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these Wrapper
and WrapperData
were causing the issue at #19671 , because they're never set, in decorators.ts
they were called decorator
and decoratorProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (not a vue expert at all, code-wise I haven't found any issues)
Then it's good this is Svelte and not Vue 😂 |
For sure. xD |
#19671
This PR fixes a regression introduced in #19580 that broke decorators in Svelte. This is the second time we've had that regression, so I've added a comment explaining that the import is weird on purpose.
It also refactors the structure around Svelte decorators and preparing them a bit. The restructuring only contains minor fixes to the logic (fixing #19671), and is mostly about readability.
I've added a few stories that tests decorators in CI (see Chromatic), and I've tested that this restructuring still works with
@storybook/addon-svelte-csf@next
.