withastro / astro

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

Conditionally apply data-astro-reload property #11324

Closed alator21 closed 4 days ago

alator21 commented 4 days ago

Astro Info

Astro                    v4.10.2
Node                     v20.11.0
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind
                         @astrojs/react

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

No response

Describe the Bug

I have an astro component with the following code

---
const items: Array<{ text: string; route: string; fullReload?: boolean }> = [
  {
    text: 'Documents',
    route: '/documents/',
    fullReload: true
  },
  { text: 'About', route: '/about' }
];
---
<ul>
    {
      items.map((item) => (
        <li>
          <a
            href={item.route}
            data-astro-reload={item.fullReload ? 'true' : undefined}>
            {item.text}
          </a>
        </li>
      ))
    }
  </ul>

I want some of my routes to have the property data-astro-reload so they can avoid some issues that i have with view-transitions.

When running astro check I get a warning

warning astro(2005): The data-astro-reload attribute does not accept a value
                 data-astro-reload={item.fullReload ? 'true' : undefined}

What's the expected result?

To not have any warning when having conditional data-astro-reload property

Link to Minimal Reproducible Example

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

Participation

matthewp commented 4 days ago

This was fixed in 2.8.1 of the compiler (it's possible your project doesn't have this yet).

matthewp commented 4 days ago

This should be fixed in 4.11.1. Let me know if its not (releasing now). https://github.com/withastro/astro/pull/11297

alator21 commented 4 days ago

Just upgraded to 4.1.1

Astro                    v4.11.1
Node                     v20.11.0
System                   Linux (x64)
Package Manager          bun
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind
                         @astrojs/react

The issue still persists.