You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an element has more than one action for the same event, Stimulus invokes the actions from left to right in the order that their descriptors appear.
This isn't entirely accurate. If you examine the dispatcher, a separate event listener is registered for each unique sequence of options (presumably to support the options to addEventListener):
This may be the expected for capture, once, and passive, but I would not have expected this for stop, prevent, self, or my custom options.
I suggest two possible resolutions:
Rework the internals of dispatcher so that only capture, once, and passive are part of the cache key. IMO this matches what most users would expect of the library.
Document this behavior without changing the code. I would find this unfortunate and reduces the utility of the action options, but is definitely less work and has less compatibility implications.
The text was updated successfully, but these errors were encountered:
As of 2024-12-31, the Stimulus reference for Actions says:
This isn't entirely accurate. If you examine the dispatcher, a separate event listener is registered for each unique sequence of options (presumably to support the options to
addEventListener
):stimulus/src/core/dispatcher.ts
Lines 83 to 88 in 8cbca6d
(where
cacheKey
is defined like so:)stimulus/src/core/dispatcher.ts
Lines 113 to 121 in 8cbca6d
Only bindings within a single event listener will be ordered; everything else is undefined:
stimulus/src/core/event_listener.ts
Lines 50 to 56 in 8cbca6d
This may be the expected for
capture
,once
, andpassive
, but I would not have expected this forstop
,prevent
,self
, or my custom options.I suggest two possible resolutions:
capture
,once
, andpassive
are part of the cache key. IMO this matches what most users would expect of the library.The text was updated successfully, but these errors were encountered: