Skip to content

Commit

Permalink
fix(svelte): partly fixes SSR with svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
divdavem committed Aug 24, 2023
1 parent 8bc8c0a commit d4d2c19
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion svelte/lib/slot/slot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ export type AdaptWidgetSlots<W extends Widget> = Widget<
export const isSvelteComponent = <Props extends object>(content: SlotContent<Props>): content is SlotSvelteComponent<Props> => {
// in prod mode, a svelte component has $set on its prototype
// in dev mode with hmr (hot module reload), a svelte component has nothing on its prototype, but its name starts with Proxy<
return typeof content === 'function' && !!content.prototype && (content.prototype.$set || /^Proxy</.test(content.name));
return (
(typeof content === 'function' && !!content.prototype && (content.prototype.$set || /^Proxy</.test(content.name))) ||
// when using Server Side Rendering, a svelte component is an object with a render function:
// (cf https://svelte.dev/docs/server-side-component-api)
typeof (content as any)?.render === 'function'
);
};

0 comments on commit d4d2c19

Please sign in to comment.