Skip to content

Conversation

@gazpachoking
Copy link
Contributor

@gazpachoking gazpachoking commented Oct 22, 2025

Before contributing, please read the contribution guidelines. Any change in behavior must be accompanied by appropriate justification, clearly describing the problem, solution, and alternatives considered.

Problem Statement

#1077
datastar-fetch events don't use the normal standard of being dispatched on the element that creates them and bubbling up the dom. This makes catching specific ones you want with a data-on:datastar-fetch more complicated.

Proposed Solution

Dispatch the events on the element where the expression calling them is defined. Fall back to dispatching on the document if the originating element is no longer in the document.

Alternatives Considered

evt.detail.el == el in every data-on:datastar-fetch (this doesn't work if you want to catch the event from a parent element though, with bubbling it would 'just work')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant