mirror of https://github.com/sveltejs/svelte
fix: ensure proxy owner set always has 1 or more members (#10577)
* fix missing owners * regression test --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/10579/head
parent
88389ad2cf
commit
ddb968cc35
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: inherit ownerlessness when creating child proxies
|
@ -0,0 +1,37 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
/** @type {typeof console.warn} */
|
||||||
|
let warn;
|
||||||
|
|
||||||
|
/** @type {any[]} */
|
||||||
|
let warnings = [];
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<button>clicks: 0</button>`,
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `<button>clicks: 1</button>`);
|
||||||
|
|
||||||
|
assert.deepEqual(warnings, []);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
import { global } from './state.svelte.js';
|
||||||
|
|
||||||
|
global.a = { b: 0 };
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => global.a.b += 1}>
|
||||||
|
clicks: {global.a.b}
|
||||||
|
</button>
|
@ -0,0 +1 @@
|
|||||||
|
export let global = $state({});
|
Loading…
Reference in new issue