Skip to content

Commit bf9d999

Browse files
committed
fix: move ownership validation into async component body
1 parent 27c90df commit bf9d999

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changeset/healthy-carpets-deny.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: move ownership validation into async component body

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ export function client_component(analysis, options) {
364364
: b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined))
365365
]);
366366

367+
if (analysis.needs_mutation_validation) {
368+
component_block.body.unshift(
369+
b.var('$$ownership_validator', b.call('$.create_ownership_validator', b.id('$$props')))
370+
);
371+
}
372+
367373
const should_inject_context =
368374
dev ||
369375
analysis.needs_context ||
@@ -434,12 +440,6 @@ export function client_component(analysis, options) {
434440
);
435441
}
436442

437-
if (analysis.needs_mutation_validation) {
438-
component_block.body.unshift(
439-
b.var('$$ownership_validator', b.call('$.create_ownership_validator', b.id('$$props')))
440-
);
441-
}
442-
443443
// we want the cleanup function for the stores to run as the very last thing
444444
// so that it can effectively clean up the store subscription even after the user effects runs
445445
if (should_inject_context) {

0 commit comments

Comments
 (0)