Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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:1 Changed 10 years ago by c4605

Version 0, edited 10 years ago by c4605 (next)

comment:3 Changed 10 years ago by Rick Waldron

Owner: set to Rick Waldron
Status: newassigned

Confirmed.

comment:5 Changed 10 years ago by Rick Waldron

Resolution: notabug
Status: assignedclosed

Sorry, but after further discussion and review, that signature isn't actually supported by jQuery.

comment:6 Changed 10 years ago by dmethvin

Component: unfiledevent
Priority: undecidedlow

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 dmethvin

Resolution: notabug
Status: closedreopened

Whoops, meant to reopen.

There is a pull request to fix the Bootstrap problem; see the reference to the bug report there as well.

https://github.com/twitter/bootstrap/pull/6970

comment:8 Changed 10 years ago by c4605

maybe we need throw an error when bind this event?

i think many people (for example me) will do like this

Last edited 10 years ago by c4605 (previous) (diff)

comment:9 in reply to:  description Changed 10 years ago by anonymous

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 Dave Methvin

Resolution: fixed
Status: reopenedclosed

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 Dave Methvin

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

Note: See TracTickets for help on using tickets.