Repository navigation
Conversation
hx-trigger="every 1s [cond]" is the documented way to filter polling, but the parser read [cond] as a modifier, so the poll ran without the filter. Written as "every 1s[cond]", the interval failed to parse and the element polled every few milliseconds. Move the filter onto the event name so it is evaluated like any other trigger filter.
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
The hx-trigger reference and the polling pattern both show a polling filter written after the interval:
On four-dev the filter is never evaluated.
__parseTriggerSpecstakeseveryas the event name and passes2s [document...]to HCON as modifiers, so the filter ends up as a stray modifier key and the element polls unconditionally. Without the space (every 2s[cond], the form the old v2 test used) it is worse: the interval key becomes2s[cond],parseIntervalreturnsundefined, andsetIntervalfires every few milliseconds.The fix moves a filter that follows the
everyinterval onto the event name before parsing, soevery 2s [cond]andevery 2s[cond]both parse to{name: 'every[cond]', '2s': true}and the filter runs through the same path asclick[cond].every[cond] 2sand plainevery 2sparse the same as before.Corresponding issue: none, the filter syntax is documented in the hx-trigger
everysectionTesting
__parseTriggerSpecs.jsfor both spellings.hx-trigger.jsthat polls with a false filter for 100ms, expects no requests, then makes the filter true and expects a request. Without the change it fails withexpected 31 to equal +0(31 requests in 100ms from two 20ms pollers).npm testpasses in Chromium (1782 passed, 4 skipped).Checklist
four-dev, since this is htmx 4 source)approved via an issue
npm run test) and verified that it succeeded