-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix: set strings as attributes, non-strings as properties if property exists #13327
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2601da9
fix: set strings as attributes, non-strings as properties if property…
Rich-Harris b27900e
simplify
Rich-Harris 5c978ad
remove draggable from list, no longer needed
Rich-Harris d3ffe52
in fact we dont need the lookup at all
Rich-Harris 3a4e83a
lint
Rich-Harris 96d82b0
beef up test
Rich-Harris 05b3542
correctly SSR translate attribute
Rich-Harris 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': patch | ||
--- | ||
|
||
fix: set strings as attributes, non-strings as properties if property exists |
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
24 changes: 24 additions & 0 deletions
24
packages/svelte/tests/runtime-runes/samples/attribute-if-string/_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,24 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, target, variant, hydrate }) { | ||
function check(/** @type {boolean} */ condition) { | ||
const divs = /** @type {NodeListOf<HTMLDivElement>} */ ( | ||
target.querySelectorAll(`.translate-${condition} div`) | ||
); | ||
|
||
divs.forEach((div, i) => { | ||
assert.equal(div.translate, condition, `${i + 1} of ${divs.length}: ${div.outerHTML}`); | ||
}); | ||
} | ||
|
||
check(false); | ||
check(true); | ||
|
||
if (variant === 'hydrate') { | ||
hydrate(); | ||
check(false); | ||
check(true); | ||
} | ||
} | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/runtime-runes/samples/attribute-if-string/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,19 @@ | ||
<div class="translate-false"> | ||
<div translate={false}></div> | ||
<div translate="no"></div> | ||
<div {...{ translate: false }}></div> | ||
<div {...{ translate: 'no' }}></div> | ||
</div> | ||
|
||
<div class="translate-true"> | ||
<div></div> | ||
<div translate={true}></div> | ||
<div translate="yes"></div> | ||
<div {...{ translate: true }}></div> | ||
<div {...{ translate: 'yes' }}></div> | ||
|
||
<div translate="false"></div> | ||
<div translate="banana"></div> | ||
<div {...{ translate: 'false' }}></div> | ||
<div {...{ translate: 'banana' }}></div> | ||
</div> |
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.
how on gods green earth did we get here
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.
uSe THe PlaTfOrM