Skip to content

Commit 6550d27

Browse files
committed
fix: prevent false-positive ownership validations due to hot reload
The component identity could change due to HMR, so we fall back to checking the filenames as well fixes #14746
1 parent 8e83127 commit 6550d27

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/ten-cougars-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: prevent false-positive ownership validations due to hot reload

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ function has_owner(metadata, component) {
216216

217217
return (
218218
metadata.owners.has(component) ||
219+
// This helps avoid false positives when using HMR, where the component function is replaced
220+
[...metadata.owners].some(
221+
(owner) => /** @type {any} */ (owner)[FILENAME] === /** @type {any} */ (component)?.[FILENAME]
222+
) ||
219223
(metadata.parent !== null && has_owner(metadata.parent, component))
220224
);
221225
}

0 commit comments

Comments
 (0)