Closed delucis closed 4 months ago
Looks like a bug with the compiler. It generates code like this:
return $$render`<div${$$addAttribute((undefined) + " astro-ojezl33t", "class")}></div>`;
We probably need to update https://github.com/withastro/compiler/blob/face55431403f20d81c4b5cd3cc4173320632ad9/internal/transform/scope-html.go#L148-L153 to generate (undefined ?? '')
instead.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
n/a / All
Describe the Bug
If a component sets the
class
attribute toundefined
, this is stringified and included in build output when usingscopedStyleStrategy: 'class'
, unlike behaviour for other attributes where setting them toundefinded
causes the attribute to be omitted in build output.For example, a component that does this:
Will render something like the following:
What's the expected result?
The build output should not include
undefined
in theclass
attribute.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-sgqbuf?file=src%2FTest.astro
Participation