mirror of https://github.com/sveltejs/svelte
parent
34079a0ec5
commit
144aec74d3
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: allow to access private fields after `this` reassignment
|
||||
@ -0,0 +1,10 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
async test({ assert, logs }) {
|
||||
assert.deepEqual(logs, ['init', 1]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,17 @@
|
||||
<script>
|
||||
class Counter {
|
||||
#count = $state();
|
||||
|
||||
constructor(){
|
||||
const instance = this;
|
||||
instance.#count = 1;
|
||||
}
|
||||
|
||||
get count(){
|
||||
return this.#count;
|
||||
}
|
||||
}
|
||||
const counter = new Counter();
|
||||
|
||||
$inspect(counter.count)
|
||||
</script>
|
||||
Loading…
Reference in new issue