mirror of https://github.com/sveltejs/svelte
fix: use `get` in constructor for deriveds (#15300)
Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/15575/head
parent
83d0c5894d
commit
ade66c6fea
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: use `get` in constructor for deriveds
|
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<p>state,derived state,derived.by derived state</p>`
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
class Foo {
|
||||
#state = $state('state')
|
||||
#derived = $derived('derived ' + this.#state);
|
||||
#derivedBy = $derived.by(() => {
|
||||
return 'derived.by ' + this.#derived
|
||||
});
|
||||
|
||||
initial
|
||||
|
||||
constructor() {
|
||||
this.initial = [this.#state, this.#derived, this.#derivedBy]
|
||||
}
|
||||
}
|
||||
const foo = new Foo()
|
||||
</script>
|
||||
|
||||
<p>{foo.initial}</p>
|
Loading…
Reference in new issue