#13639 closed bug (invalid)
Bug with event.stopImmediatePropagation() or documentation
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
There is either a bug with (event.stopImmediatePropagation()) or the documentation needs clarification.
- event.stopImmediatePropagation() does not prevent all handlers from firing. Only handlers of the 'same' type as the handler that called the function.
- Or you have not specified in the documentation correctly if this is not a bug.
Please review: http://jsfiddle.net/XhqeG/
Change History (6)
comment:1 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
Status: | pending → new |
---|
If I have 2 event handlers and I put a condition in the first one that makes it so the next shouldn't fire [using event.stopImmediatePropagation()] then that's what I expect.
$(this).on('mousedown', function(event){ if( foo == 'bar'){ event.stopImmediatePropagation(); } }).on('click', function(event){ if(foo == 'bar'){ alert('I should never alert!'); } });
FROM THE DOCUMENTATION:
Description: Keeps the rest of the handlers from being executed and prevents the event from bubbling up the DOM tree.
This is incorrect. It only keeps handlers of the same event type from being executed.
comment:3 Changed 10 years ago by
Status: | new → pending |
---|
These are two different events that happen to be caused by the same user action. You've stopped the propagation of mousedown
, so the rest of the handlers for mousedown
do not execute. After mousedown
completes, a click
event starts. You have not done anything on the click
event to stop propagation.
The code is working correctly. You can try the exact same thing with native DOM events.
@dmethvin has asked you what update you would like to see in the wording, but so far you haven't suggested any changes.
comment:4 Changed 10 years ago by
You said it in your reply.
You've stopped the propagation of mousedown
This is what is 'not' clear. I'm expecting 'all' handlers from being executed. Clearly it is not stopping 'all,' just all of the same event type.
It should read:
Keeps the rest of the handlers of the same event type from being executed and prevents the event from bubbling up the DOM tree.
comment:5 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
comment:6 Changed 10 years ago by
My comment was added above, however, I forgot to include my email address so it was set to 'anonymous.' Please see above (comment 4).
So what wording would you propose? True to its name,
.stopImmediatePropagation()
does stop the propagation of the current event so that no other handlers fire. Why would it affect *other* events? The jQuery documentation is generally meant to be used by developers with an understanding of the W3C event model, and there is nothing in the standard about this.