Skip to content

Commit 970aa7c

Browse files
authored
fix: prevent false-positive ownership validations due to hot reload (#15154)
The component identity could change due to HMR, so we fall back to checking the filenames as well fixes #14746
1 parent 83f00eb commit 970aa7c

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
@@ -220,6 +220,10 @@ function has_owner(metadata, component) {
220220

221221
return (
222222
metadata.owners.has(component) ||
223+
// This helps avoid false positives when using HMR, where the component function is replaced
224+
[...metadata.owners].some(
225+
(owner) => /** @type {any} */ (owner)[FILENAME] === /** @type {any} */ (component)?.[FILENAME]
226+
) ||
223227
(metadata.parent !== null && has_owner(metadata.parent, component))
224228
);
225229
}

0 commit comments

Comments
 (0)