-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix : bug "$0 is not defined" with svelte:element and a single class with a function call #15396
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
Merged
+88
−2
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f63f9d
add spread to test
adiguba 5d6bb2f
fix #15386
adiguba b07781d
Merge branch 'main' of https://github.com/sveltejs/svelte
adiguba 6bc3416
fix #15392
adiguba 311c8ff
test
adiguba ea0c942
changeset
adiguba 22c5338
use is_text_attribute
adiguba 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 hidden or 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 : bug "$0 is not defined" on svelte:element with a function call on class |
This file contains hidden or 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
60 changes: 60 additions & 0 deletions
60
packages/svelte/tests/runtime-runes/samples/svelte-element-css-hash/_config.js
This file contains hidden or 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,60 @@ | ||
import { flushSync } from 'svelte'; | ||
import { ok, test } from '../../test'; | ||
|
||
export default test({ | ||
html: ` | ||
<div></div> | ||
<div class="red svelte-p153w3"></div> | ||
<div></div> | ||
<div class="red svelte-p153w3"></div> | ||
<div class="blue svelte-p153w3"></div> | ||
<div class="blue svelte-p153w3"></div> | ||
`, | ||
|
||
async test({ assert, target, component }) { | ||
component.active = true; | ||
flushSync(); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div></div> | ||
<div class="red svelte-p153w3"></div> | ||
<div class="active"></div> | ||
<div class="red svelte-p153w3 active"></div> | ||
<div class="blue svelte-p153w3"></div> | ||
<div class="blue svelte-p153w3 active"></div> | ||
` | ||
); | ||
|
||
component.tag = 'span'; | ||
flushSync(); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<span></span> | ||
<span class="red svelte-p153w3"></span> | ||
<span class="active"></span> | ||
<span class="red svelte-p153w3 active"></span> | ||
<span class="blue svelte-p153w3"></span> | ||
<span class="blue svelte-p153w3 active"></span> | ||
` | ||
); | ||
|
||
component.active = false; | ||
flushSync(); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<span></span> | ||
<span class="red svelte-p153w3"></span> | ||
<span class=""></span> | ||
<span class="red svelte-p153w3"></span> | ||
<span class="blue svelte-p153w3"></span> | ||
<span class="blue svelte-p153w3"></span> | ||
` | ||
); | ||
} | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/runtime-runes/samples/svelte-element-css-hash/main.svelte
This file contains hidden or 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,20 @@ | ||
<script> | ||
let { tag = "div", active = false } = $props(); | ||
|
||
function cn(classname) { | ||
return classname; | ||
} | ||
</script> | ||
|
||
<svelte:element this={tag}></svelte:element> | ||
<svelte:element this={tag} class="red"></svelte:element> | ||
<svelte:element this={tag} class:active={active}></svelte:element> | ||
<svelte:element this={tag} class="red" class:active={active}></svelte:element> | ||
<svelte:element this={tag} class={cn("blue")}></svelte:element> | ||
<svelte:element this={tag} class={cn("blue")} class:active={active}></svelte:element> | ||
|
||
<style> | ||
.red { | ||
color: red; | ||
} | ||
</style> |
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.
Uh oh!
There was an error while loading. Please reload this page.