This commit is contained in:
Valentin Palkovic 2024-05-27 14:52:59 +02:00
parent 9e85db1ab6
commit 21f0964491

View File

@ -13,13 +13,13 @@
if (on && svelteVersion < 5) {
// Attach Svelte event listeners in Svelte v4
// In Svelte v5 this is not possible anymore as instances are no longer classes with $on() properties, so it will be a no-op
onMount(() => {
onMount(() => {
Object.entries(on).forEach(([eventName, eventCallback]) => {
// instance can be undefined if a decorator doesn't have <slot/>
const inst = instance ?? decoratorInstance;
inst?.$on?.(eventName, eventCallback)
});
});
});
}
</script>