Ticket #2530448 (closed defect)
Reporter John McLaughlin |
Opened: 06/19/11 Last modified: 08/18/11 Status: closed Type: defect Resolution: fixed |
Owner Luke Smith |
Target Release: 3.4.0 Priority: P4 (low) |
|---|---|---|---|
| Summary: | Document return false for event subscribers | ||
| Description: | Apparently if the return value is "false" from a handler that is defined before a "fireOnce" event is fired, subsequent handlers that are also defined before the "fire" are ignored. This doesn't seem This is easy to work around, but tough to track down, especially since the behavior can be different depending on the timing of the event firing. I looked at the source code, and it appears that this |
||
| Type: | defect | Observed in Version: | 3.3.0 |
| Component: | Event | Severity: | S4 (low) |
| Assigned To: | Luke Smith | Target Release: | 3.4.0 |
| Location: | API Documentation | Priority: | P4 (low) |
| Tags: | fireOnce,custom,event | Relates To: | |
| Browsers: | N/A | ||
| URL: | |||
| Test Information: |
|
||
Change History
|
Posted: 06/20/11
|
|
Posted: 06/20/11
That sounds like it would be most consistent. Fortunately it turns out that isn't as much of a problem as I had feared, since the preventDefault/stopPropagation behavior only occurs from an actual "false" return value, but no other falsey values including "undefined'. However it seems to me that the 'false' return value behavior (independent of the fireOnce issue) is worthy of a paragraph in the main Event documentation page, or at least the API docs. You can even label it as a "feature" ;) |
|
Posted: 06/27/11
I've created #2530477 to track the code related modification. I'll leave this ticket to track the documentation change. Docs I can probably do for 3.4.0, but not the code change. |
|
Posted: 06/27/11
|
|
Posted: 07/27/11
|
|
Posted: 08/4/11
I've added verbiage in the Event user guide and EventTarget's on() method API docs for 3.4.0. More EventTarget methods should have their docs updated to make sense in the context of Node, but it's a start. |
|
Posted: 08/4/11
Add API doc content for on + return falsennPartial solution, as the other methods neednto have language friendly for reading on thenNode API docs (inherited methods).nnFixes #2530448 |
|
Posted: 08/18/11
|
fireOnce events immediately execute new subscription callbacks after they have been fired. Separately, returning false from an event subscriber (unfortunately) has been overloaded to be equivalent to e.preventDefault(); e.stopImmediatePropagation(). The latter call stops the processing of further subscribers. However, it doesn't stop further subscriptions from being made for a subsequent fire().
The same is true for fireOnce events, but each call to on() or after() after the event is fired ignores previous subscriptions (they've already been notified) and is effectively a call to on()+fire().
So it sounds like what you're asking for is that if a fireOnce event is stopped with stopImmediatePropagation or return false, that post-fire() subscriptions don't execute.
Is this a fair summation?