-
Notifications
You must be signed in to change notification settings - Fork 59
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
class and class:list conflict #998
Comments
I don't know if this is actually a bug or not, but you can pass |
You can use https://live-astro-compiler.vercel.app to inspect how Astro compiles the code, and I think it revealed some issues here. It seems like the compiler is not correctly constructing the array passed to |
I try the compiler and yep ---
const name = 'work'
---
<!-- Work fine -->
<div class={`container ${work}`}></div>
<div class="container" class:list={}></div>
<div class='container' class:list={}></div>
<!-- Not work -->
<div class={`container ${work}`} class:list={}></div>
<div class={name} class:list={}></div>
<div class={"container " + name} class:list={}></div>
<div class={"container"} class:list={}></div>
<!-- Crash -->
<div class={'container'} class:list={}></div>
<div class={'container ' + name} class:list={}></div> Output //Work Fine
`
<div${$$addAttribute(`container ${work}`, "class")}></div>
<div${$$addAttribute(['container', ], "class:list")}></div>
<div${$$addAttribute(['container', ], "class:list")}></div>
`
//Not Work
`
<div${$$addAttribute(['`container ${work}`', ], "class:list")}></div>
<div${$$addAttribute(['name', ], "class:list")}></div>
<div${$$addAttribute(['"container " + name', ], "class:list")}></div>
<div${$$addAttribute(['"container"', ], "class:list")}></div>
`
//Crash
`
<div${$$addAttribute([''container'', ], "class:list")}></div>
<div${$$addAttribute([''container ' + name', ], "class:list")}></div>
` |
If someone wants work on this, I believe the issue is happening here The quotes should be set according to the |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Attribute
class
with template string not work withclass:list
directiverender
What's the expected result?
render
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-6vn7fi?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: