Repository navigation
Conversation
__trigger logged the original event name but dispatched the metaCharacter-adjusted one, so logAll/error/warn output named events that no listener receives. Compute the dispatched name once and use it for logging and dispatch. Document that metaCharacter also renames dispatched events. Closes bigskysoftware#4108
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With
htmx.config.metaCharacterset,__triggerdispatches the adjusted event name but logs the original one. WithmetaCharacter = '-',logAllprintshtmx: htmx:before:request, but the event that fires ishtmx-before-request. The same mismatch affects thedetail.erroranddetail.warnlog lines, so the console names events that no listener can receive.This change computes the dispatched name once at the top of
__triggerand uses it for the three log calls and fortrigger().__triggerExtensionsstill receives the original name, because extension methods are keyed oneventName.replace(/:/g, '_')and would stop matching otherwise. Without ametaCharacter, output is unchanged.The issue also asks whether the renaming itself should go. I kept it, since the 4.x config table describes
metaCharacteras the "separator character in attribute/event names". Instead I updated themetaCharacterdocs, which only mentioned attribute modifiers, to say that dispatched event names change too.Out of scope: events that extensions fire through the public
htmx.trigger()are not renamed (#4084).Corresponding issue: #4108
Closes #4108
Testing
logAll logs the dispatched event name when metaCharacter is settotest/tests/unit/logger.js. It fails onfour-dev(the log containshtmx:custom) and passes with this change.npm test(Chromium): 1781 passed, 0 failed, 4 skipped.python3 src/scripts/content/check.py: OK.Checklist
masterfor website changes,devforsource changes) (targeting
four-dev, since this is an htmx 4 source fix)approved via an issue
npm run test) and verified that it succeeded