mirror of https://github.com/sveltejs/svelte
Revert "fix: ensure deep mutation ownership widening" (#11155)
* Revert "fix: ensure deep mutation ownership widening (#11094)"
This reverts commit 8578857332
.
* don't delete the changeset, it's already merged
pull/11161/head
parent
be842425f5
commit
dc6a8398d1
@ -1,35 +0,0 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
/** @type {typeof console.warn} */
|
||||
let warn;
|
||||
|
||||
/** @type {any[]} */
|
||||
let warnings = [];
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
before_test: () => {
|
||||
warn = console.warn;
|
||||
|
||||
console.warn = (...args) => {
|
||||
warnings.push(...args);
|
||||
};
|
||||
},
|
||||
|
||||
after_test: () => {
|
||||
console.warn = warn;
|
||||
warnings = [];
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
await btn?.click();
|
||||
await tick();
|
||||
assert.deepEqual(warnings.length, 0);
|
||||
}
|
||||
});
|
@ -1,25 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { setContext } from 'svelte';
|
||||
import Sub from './sub.svelte';
|
||||
|
||||
class Person1 {
|
||||
value = $state({ person: 'John', age: 33 })
|
||||
}
|
||||
const class_nested_state = $state(new Person1());
|
||||
|
||||
class Person2 {
|
||||
person = $state('John');
|
||||
age = $state(33);
|
||||
}
|
||||
const state_nested_class = $state({ value: new Person2() });
|
||||
|
||||
const nested_state = $state({ person: 'John', age: 33 });
|
||||
|
||||
setContext('foo', {
|
||||
nested_state,
|
||||
get class_nested_state() { return class_nested_state },
|
||||
get state_nested_class() { return state_nested_class }
|
||||
})
|
||||
</script>
|
||||
|
||||
<Sub {class_nested_state} {state_nested_class} {nested_state} />
|
@ -1,11 +0,0 @@
|
||||
<script>
|
||||
import { getContext } from "svelte";
|
||||
|
||||
const foo = getContext('foo')
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
foo.class_nested_state.value.age++;
|
||||
foo.state_nested_class.value.age++;
|
||||
foo.nested_state.age++;
|
||||
}}>mutate</button>
|
Loading…
Reference in new issue