Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow for literal property definition with state on classes (#1…
- Loading branch information
1 parent
c7bdef5
commit 2d2508a
Showing
5 changed files
with
57 additions
and
5 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 | ||
--- | ||
|
||
feat: allow for literal property definition with state on classes |
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
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-state-with-literal/_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>false</button>`, | ||
|
||
async test({ assert, target }) { | ||
const btn = target.querySelector('button'); | ||
|
||
await btn?.click(); | ||
assert.htmlEqual(target.innerHTML, `<button>true</button>`); | ||
|
||
await btn?.click(); | ||
assert.htmlEqual(target.innerHTML, `<button>false</button>`); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/class-state-with-literal/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 Toggle { | ||
"aria-pressed" = $state(false); | ||
toggle(){ | ||
this["aria-pressed"] = !this["aria-pressed"] | ||
} | ||
} | ||
const toggle = new Toggle(); | ||
</script> | ||
|
||
<button on:click={() => toggle.toggle()}>{toggle["aria-pressed"]}</button> |