Astro v5: AlpineJS alpine:init event not working
Opened this issue · 1 comments
xandermann commented
Astro Info
Astro v5.0.4
Node v23.4.0
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations @astrojs/alpinejs
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
The event of AlpineJS alpine:init
is not working anymore in Astro 5.
document.addEventListener('alpine:init', () => {
console.log("test") // never called in astro 5
});
It works in astro 4.16.17, but not in astro 5.0.4
What's the expected result?
document.addEventListener('alpine:init', () => {
// this event should be triggered
});
The AlpineJS documentation shows that it should work : https://alpinejs.dev/globals/alpine-data
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-sscqvr22?file=src%2Fpages%2Findex.astro
Participation
- I am willing to submit a pull request for this issue.
florian-lefebvre commented
I'm surprised this even worked in v4, since the recommend way for Astro is to use the entrypoint option, see updated reproduction.
I wonder is this is caused by this breaking change https://docs.astro.build/en/guides/upgrade-to/v5/#script-tags-are-rendered-directly-as-declared