Skip to content

Commit

Permalink
fix: preserve reactivity in props (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb authored Jul 17, 2024
1 parent 7ea7725 commit e42d361
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/syv.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ComponentProps, ComponentType, SvelteComponent } from 'svelte';
import type { Demand, LazyComponent, SyvOptions } from './types.js';
import { mount as create, unmount } from 'svelte';
import { augment } from 'mauss/std';

let instance: ReturnType<typeof create>;

Expand All @@ -13,13 +12,13 @@ export function mount<T extends SvelteComponent>(
) {
instance && unmount(instance); // destroy here so it keeps the out transition

const options = Object.assign({ 'syv:intro': true }, demanded);
const props = Object.keys(options).filter((k) => !k.includes(':'));
const internal = Object.assign({ 'syv:intro': true }, demanded);
if (demanded) delete demanded['syv:intro'], delete demanded['syv:anchor'];
// @ts-expect-error - not sure what's going on here
instance = create(component, {
intro: options['syv:intro'],
target: options['syv:anchor'] || document.body,
props: augment(options).filter(props),
intro: internal['syv:intro'],
target: internal['syv:anchor'] || document.body,
props: demanded, // pass the object as-is to preserve reactivity
});
}

Expand Down

0 comments on commit e42d361

Please sign in to comment.