Skip to content

Commit

Permalink
fix: account for mutations in script module in ownership check (#14253)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored Nov 10, 2024
1 parent 7bc94b9 commit ae9f53a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-laws-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: account for mutations in script module in ownership check
3 changes: 3 additions & 0 deletions packages/svelte/src/internal/client/dev/ownership.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export function get_component() {
}

for (const module of modules) {
if (module.end == null) {
return null;
}
if (module.start.line < entry.line && module.end.line > entry.line) {
return module.component;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { test } from '../../test';

export default test({
compileOptions: {
dev: true
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script module>
let obj = $state({});
obj.test = "hi!";
</script>

<h1>Values: {JSON.stringify(obj)}</h1>

0 comments on commit ae9f53a

Please sign in to comment.