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 <5968653+dummdidumm@users.noreply.github.com>
pull/14694/head
Dominic Gannaway 9 months ago committed by GitHub
parent 7aa80fc2a7
commit 8ba1b9ddd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: avoid mutation validation for invalidate_inner_signals

@ -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';
@ -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);
}
}
}

@ -0,0 +1,12 @@
<script>
let { children } = $props()
const snippetProps = $derived.by(() => ({
id: '123',
name: 'my-select'
}))
</script>
{@render children({ props: snippetProps })}

@ -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>'
});

@ -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>
Loading…
Cancel
Save