Skip to content

unify hx-on and hx-trigger modifier grammar#3798

Open
scriptogre wants to merge 2 commits into
bigskysoftware:four-devfrom
scriptogre:4.0/hx-on
Open

unify hx-on and hx-trigger modifier grammar#3798
scriptogre wants to merge 2 commits into
bigskysoftware:four-devfrom
scriptogre:4.0/hx-on

Conversation

@scriptogre
Copy link
Copy Markdown
Collaborator

@scriptogre scriptogre commented May 14, 2026

  • enable hx-on="eventSpec => code" syntax that supports all existing hx-trigger modifiers (e.g. [filter], once, delay, changed, from, etc.).

  • add new modifiers to both hx-on and hx-trigger: prevent, stop, halt, capture, passive, from:self, from:outside

  • remove undocumented dot modifiers (.prevent, .stop, .halt, .once, .self, .outside, .capture, .passive, .cc) from hx-on:event syntax

  • rename __onTrigger -> __onEvent

  • rename __parseTriggerSpecs -> __parseEventSpecs

  • remove hx-trigger queue modifier from docs (no-op in 4.0)

  • update tests, docs, and extension references

- enable hx-on="eventSpec => code" syntax that supports all existing hx-trigger modifiers (e.g. [filter], once, delay, changed, from, etc.).

- add new modifiers to both hx-on and hx-trigger: prevent, stop, halt, capture, passive, from:self, from:outside
- remove undocumented dot modifiers (.prevent,
.stop, .halt, .once, .self, .outside, .capture, .passive, .cc) from hx-on:event syntax
- rename __onTrigger -> __onEvent
- rename __parseTriggerSpecs -> __parseEventSpecs
- remove hx-trigger queue modifier from docs (no-op in 4.0)
- update tests, docs, and extension references
Change the grammar separator in hx-on="event => code" from => to ->.
This avoids visual ambiguity with JavaScript arrow functions that may
appear in the handler code.

Updated:
- src/htmx.js: indexOf('=>') → indexOf('->')
- test/tests/attributes/hx-on.js: all hx-on attribute values
- test/tests/ext/hx-live.js: hx-live helper tests using hx-on
- www docs: all examples and explanations in hx-on.md
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