Skip to content

Commit ab9c640

Browse files
committed
make it work with HMR
1 parent 7b2fc9c commit ab9c640

File tree

1 file changed

+5
-1
lines changed
  • packages/svelte/src/internal/client/dev

1 file changed

+5
-1
lines changed

packages/svelte/src/internal/client/dev/hmr.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { block, branch, destroy_effect } from '../reactivity/effects.js';
22
import { set_should_intro } from '../render.js';
33
import { get } from '../runtime.js';
4+
import { check_target } from './legacy.js';
45

56
/**
67
* @template {(anchor: Comment, props: any) => any} Component
@@ -11,7 +12,7 @@ export function hmr(source) {
1112
* @param {Comment} anchor
1213
* @param {any} props
1314
*/
14-
return (anchor, props) => {
15+
return function (anchor, props) {
1516
let instance = {};
1617

1718
/** @type {import("#client").Effect} */
@@ -20,6 +21,9 @@ export function hmr(source) {
2021
block(() => {
2122
const component = get(source);
2223

24+
// @ts-expect-error
25+
check_target(new.target && component);
26+
2327
if (effect) {
2428
// @ts-ignore
2529
for (var k in instance) delete instance[k];

0 commit comments

Comments
 (0)