Skip to content

Commit

Permalink
fix: avoid mutation validation for invalidate_inner_signals (#14688)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
trueadm and dummdidumm authored Dec 12, 2024
1 parent 7aa80fc commit 8ba1b9d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-pandas-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: avoid mutation validation for invalidate_inner_signals
7 changes: 4 additions & 3 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from './constants.js';
import { flush_tasks } from './dom/task.js';
import { add_owner } from './dev/ownership.js';
import { mutate, set, source } from './reactivity/sources.js';
import { internal_set, set, source } from './reactivity/sources.js';
import { destroy_derived, execute_derived, update_derived } from './reactivity/deriveds.js';
import * as e from './errors.js';
import { lifecycle_outside_component } from '../shared/errors.js';
Expand Down Expand Up @@ -960,11 +960,12 @@ export function invalidate_inner_signals(fn) {
if ((signal.f & LEGACY_DERIVED_PROP) !== 0) {
for (const dep of /** @type {Derived} */ (signal).deps || []) {
if ((dep.f & DERIVED) === 0) {
mutate(dep, null /* doesnt matter */);
// Use internal_set instead of set here and below to avoid mutation validation
internal_set(dep, dep.v);
}
}
} else {
mutate(signal, null /* doesnt matter */);
internal_set(signal, signal.v);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
let { children } = $props()
const snippetProps = $derived.by(() => ({
id: '123',
name: 'my-select'
}))
</script>

{@render children({ props: snippetProps })}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: '<select id="123" name="my-select"><option>A</option><option>B</option><option>C</option></select>'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<svelte:options runes={false} />

<script>
import { writable } from 'svelte/store'
import Comp from './Comp.svelte'
const myStore = writable('')
</script>

<Comp>
{#snippet children({ props })}
<select {...props} bind:value={$myStore} >
<option>A</option>
<option>B</option>
<option>C</option>
</select>
{/snippet}
</Comp>

0 comments on commit 8ba1b9d

Please sign in to comment.