-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow for literal property definition with state on classes #11326
Merged
dummdidumm
merged 8 commits into
sveltejs:main
from
paoloricciuti:literal-property-definition
Apr 29, 2024
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d6d1a26
feat: allow for literal property definition with state on classes
paoloricciuti 15a7cb0
Create honest-nails-share.md
paoloricciuti ef5a0df
Update honest-nails-share.md
paoloricciuti ec329a9
chore: rename class in test
paoloricciuti 4136033
fix: replaceAll and use regex
paoloricciuti d6484a5
Update honest-nails-share.md
paoloricciuti c7475d6
Merge branch 'main' into literal-property-definition
dummdidumm 99d3a06
simplify
dummdidumm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": minor | ||
--- | ||
|
||
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
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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't think this is enough - there could be all sorts of whacky characters in there, better to use a "non-valid ID identifier" regex (I believe there exists one already)
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.
Oh great, yesterday I started to think of other invalid characters but nothing come to mind...I'll update soon
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.
Also just realized I need
replaceAll
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.
@dummdidumm fixed it in the new commit...should i add more tests for all the same thing that were tested with normal identifiers?