withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
44.08k stars 2.29k forks source link

Astro unexpectedly stringifies `undefined` class attribute #11413

Closed delucis closed 4 days ago

delucis commented 4 days ago

Astro Info

Astro                    v4.11.5
Node                     v18.20.3
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

n/a

Describe the Bug

When using the When using the 'where' or 'class' scopedStyleStrategy, an undefined class attribute passed down to a child component is incorrectly stringified.

For example, <ChildComponent class={undefined} /> can receive undefined astro-XXXX as the value of Astro.props.class. (Assuming the parent component is also using scoped styles and therefore has an associated hash ID.)

What's the expected result?

<ChildComponent class={undefined} /> should receive only astro-XXXX as the value of Astro.props.class, without undefined appearing in the class string.


Notes

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-i2qay8?file=src%2Fpages%2Findex.astro

Participation

delucis commented 4 days ago

I knew this seemed familiar — I already reported this once in the past https://github.com/withastro/compiler/issues/1005 😅

Guess I’ll close this in favour of that one then.