mirror of https://github.com/sveltejs/svelte
fix: ensure class constructor values are proxied (#9888)
* fix: ensure class constructor values are proxied * debuggerpull/9889/head
parent
646c0c432b
commit
bdd63c8187
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure class constructor values are proxied
|
@ -0,0 +1,15 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
await btn?.click();
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button>`);
|
||||
|
||||
await btn?.click();
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
class Counter {
|
||||
#count = $state();
|
||||
|
||||
constructor(v) {
|
||||
this.#count = v;
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.#count;
|
||||
}
|
||||
}
|
||||
const counter = new Counter({ count: 0 });
|
||||
</script>
|
||||
|
||||
<button on:click={() => counter.count.count++}>{counter.count.count}</button>
|
@ -0,0 +1,15 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<button>0</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
await btn?.click();
|
||||
assert.htmlEqual(target.innerHTML, `<button>1</button>`);
|
||||
|
||||
await btn?.click();
|
||||
assert.htmlEqual(target.innerHTML, `<button>2</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
class Counter {
|
||||
count = $state();
|
||||
|
||||
constructor(v) {
|
||||
this.count = v;
|
||||
}
|
||||
}
|
||||
const counter = new Counter({ count: 0 });
|
||||
</script>
|
||||
|
||||
<button on:click={() => counter.count.count++}>{counter.count.count}</button>
|
Loading…
Reference in new issue