Skip to content

Commit 8ba1b9d

Browse files
trueadmdummdidumm
andauthored
fix: avoid mutation validation for invalidate_inner_signals (#14688)
* fix: avoid mutation validation for invalidate_inner_signals * add test * Update packages/svelte/src/internal/client/runtime.js --------- Co-authored-by: Simon H <[email protected]>
1 parent 7aa80fc commit 8ba1b9d

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

.changeset/strong-pandas-provide.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: avoid mutation validation for invalidate_inner_signals

packages/svelte/src/internal/client/runtime.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from './constants.js';
3030
import { flush_tasks } from './dom/task.js';
3131
import { add_owner } from './dev/ownership.js';
32-
import { mutate, set, source } from './reactivity/sources.js';
32+
import { internal_set, set, source } from './reactivity/sources.js';
3333
import { destroy_derived, execute_derived, update_derived } from './reactivity/deriveds.js';
3434
import * as e from './errors.js';
3535
import { lifecycle_outside_component } from '../shared/errors.js';
@@ -960,11 +960,12 @@ export function invalidate_inner_signals(fn) {
960960
if ((signal.f & LEGACY_DERIVED_PROP) !== 0) {
961961
for (const dep of /** @type {Derived} */ (signal).deps || []) {
962962
if ((dep.f & DERIVED) === 0) {
963-
mutate(dep, null /* doesnt matter */);
963+
// Use internal_set instead of set here and below to avoid mutation validation
964+
internal_set(dep, dep.v);
964965
}
965966
}
966967
} else {
967-
mutate(signal, null /* doesnt matter */);
968+
internal_set(signal, signal.v);
968969
}
969970
}
970971
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script>
2+
3+
let { children } = $props()
4+
5+
const snippetProps = $derived.by(() => ({
6+
id: '123',
7+
name: 'my-select'
8+
}))
9+
10+
</script>
11+
12+
{@render children({ props: snippetProps })}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: '<select id="123" name="my-select"><option>A</option><option>B</option><option>C</option></select>'
5+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<svelte:options runes={false} />
2+
3+
<script>
4+
import { writable } from 'svelte/store'
5+
import Comp from './Comp.svelte'
6+
7+
const myStore = writable('')
8+
9+
</script>
10+
11+
<Comp>
12+
{#snippet children({ props })}
13+
<select {...props} bind:value={$myStore} >
14+
<option>A</option>
15+
<option>B</option>
16+
<option>C</option>
17+
</select>
18+
{/snippet}
19+
</Comp>

0 commit comments

Comments
 (0)