-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 : bug "$0 is not defined" with svelte:element and a single class with a function call #15396
Open
adiguba
wants to merge
6
commits into
sveltejs:main
Choose a base branch
from
adiguba:fix/15392
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+90
−2
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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 : bug "$0 is not defined" on svelte:element with a function call on class |
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
60 changes: 60 additions & 0 deletions
60
packages/svelte/tests/runtime-runes/samples/svelte-element-css-hash/_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,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 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.
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.
I might be wrong but there should be a
is_text_attrobute
utility somewhere...can you check if that's the case and use that?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.
Will change that in the morning