-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure class constructor values are proxied (#9888)
* fix: ensure class constructor values are proxied * debugger
- Loading branch information
Showing
6 changed files
with
95 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure class constructor values are proxied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/svelte/tests/runtime-runes/samples/class-private-state-proxy/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>`); | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-runes/samples/class-private-state-proxy/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
15 changes: 15 additions & 0 deletions
15
packages/svelte/tests/runtime-runes/samples/class-state-proxy/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>`); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/class-state-proxy/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
bdd63c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
svelte-5-preview – ./sites/svelte-5-preview
svelte-5-preview.vercel.app
svelte-octane.vercel.app
svelte-5-preview-svelte.vercel.app
svelte-5-preview-git-main-svelte.vercel.app