mirror of https://github.com/sveltejs/svelte
fix: ignore mutation validation for props that are not proxies in more cases (#15759)
This fixes an off-by-one error - we did not bail if the top level of the prop wasn't a state already. Fixes #15727pull/15756/head
parent
bdf033e30f
commit
26e574f27f
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ignore mutation validation for props that are not proxies in more cases
|
@ -0,0 +1,18 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
test({ assert, target, warnings }) {
|
||||
const btn = target.querySelector('button');
|
||||
btn?.click();
|
||||
flushSync();
|
||||
|
||||
assert.deepEqual(warnings, []);
|
||||
},
|
||||
|
||||
warnings: []
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
let { klass, getter_setter } = $props();
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
klass.y = 2;
|
||||
getter_setter.y = 2;
|
||||
}}>mutate</button>
|
@ -0,0 +1,21 @@
|
||||
<script>
|
||||
import Child from './child.svelte';
|
||||
|
||||
class X {
|
||||
y = $state(1);
|
||||
}
|
||||
|
||||
const klass = new X();
|
||||
|
||||
let y = $state(1);
|
||||
const getter_setter = {
|
||||
get y() {
|
||||
return y;
|
||||
},
|
||||
set y(value) {
|
||||
y = value;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Child {klass} {getter_setter} />
|
Loading…
Reference in new issue