Sam 2 days ago committed by GitHub
commit 4898a11171
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: catch errors thrown during component mount to prevent source from losing tracking

@ -38,21 +38,26 @@ export function hmr(fn) {
destroy_effect(effect);
}
effect = branch(() => {
// when the component is invalidated, replace it without transitions
if (ran) set_should_intro(false);
// preserve getters/setters
Object.defineProperties(
instance,
Object.getOwnPropertyDescriptors(
// @ts-expect-error
new.target ? new component(anchor, props) : component(anchor, props)
)
);
if (ran) set_should_intro(true);
});
try {
effect = branch(() => {
// when the component is invalidated, replace it without transitions
if (ran) set_should_intro(false);
// preserve getters/setters
Object.defineProperties(
instance,
Object.getOwnPropertyDescriptors(
// @ts-expect-error
new.target ? new component(anchor, props) : component(anchor, props)
)
);
if (ran) set_should_intro(true);
});
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}
}, EFFECT_TRANSPARENT);
ran = true;

Loading…
Cancel
Save