Skip to content

Commit

Permalink
fix: prevent false-positive ownership validations due to hot reload (#…
Browse files Browse the repository at this point in the history
…15154)

The component identity could change due to HMR, so we fall back to checking the filenames as well

fixes #14746
  • Loading branch information
dummdidumm authored Jan 30, 2025
1 parent 83f00eb commit 970aa7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/ten-cougars-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: prevent false-positive ownership validations due to hot reload
4 changes: 4 additions & 0 deletions packages/svelte/src/internal/client/dev/ownership.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ function has_owner(metadata, component) {

return (
metadata.owners.has(component) ||
// This helps avoid false positives when using HMR, where the component function is replaced
[...metadata.owners].some(
(owner) => /** @type {any} */ (owner)[FILENAME] === /** @type {any} */ (component)?.[FILENAME]
) ||
(metadata.parent !== null && has_owner(metadata.parent, component))
);
}
Expand Down

0 comments on commit 970aa7c

Please sign in to comment.