#13471 closed bug (fixed)
Stack overflow if element which binded pure namespace event unbind a pure namespace event
Reported by: | c4605 | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | event | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
$(document).on(".test",function(){console.log("test success")}).off(".test") // Stack Overflow
Change History (11)
comment:2 Changed 10 years ago by
bootstrap bind event by this way: https://github.com/twitter/bootstrap/blob/master/js/bootstrap-dropdown.js#L161
comment:4 Changed 10 years ago by
comment:5 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | assigned → closed |
Sorry, but after further discussion and review, that signature isn't actually supported by jQuery.
comment:6 Changed 10 years ago by
Component: | unfiled → event |
---|---|
Priority: | undecided → low |
Reopening so we can turn this into a no-op rather than an infinite loop, but the root problem is this line:
.on('.dropdown-menu', function (e) { e.stopPropagation() })
You must specify a type name. The docs say the type name may be qualified by a namespace, but not that the type name is optional. It's only optional when removing events.
comment:7 Changed 10 years ago by
Resolution: | notabug |
---|---|
Status: | closed → reopened |
Whoops, meant to reopen.
There is a pull request to fix the Bootstrap problem; see the reference to the bug report there as well.
comment:8 Changed 10 years ago by
maybe we need throw an error when bind this event?
i think many people (for example me) will do like this
comment:9 Changed 10 years ago by
thnk q very much Replying to c4605:
$(document).on(".test",function(){console.log("test success")}).off(".test") // Stack Overflow
comment:10 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fix #13471. $().on(".xyz"...) should avoid later crash.
If the event type is an empty string we end up hanging in .off() which makes for mighty hard debugging. Instead treat it as a no-op. Docs seem clear this is not allowed.
Changeset: 2bbc3d5860b81e128cd92f865673e10046caac7d
comment:11 Changed 10 years ago by
Fix #13471. $().on(".xyz"...) should avoid later crash.
If the event type is an empty string we end up hanging in .off() which makes for mighty hard debugging. Instead treat it as a no-op. Docs seem clear this is not allowed.
Changeset: f5163914fa1a751aa5bf10ce48c4b5307d65ed90
http://jsfiddle.net/vTqH3/