Bug Tracker

Ticket #13471 (closed bug: fixed)

Opened 22 months ago

Last modified 22 months ago

Stack overflow if element which binded pure namespace event unbind a pure namespace event

Reported by: c4605 Owned by: rwaldron
Priority: low Milestone: None
Component: event Version: 1.9.1
Keywords: Cc:
Blocking: Blocked by:

Description

$(document).on(".test",function(){console.log("test success")}).off(".test") // Stack Overflow

Change History

comment:1 Changed 22 months ago by c4605

Last edited 22 months ago by c4605 (previous) (diff)

comment:3 Changed 22 months ago by rwaldron

  • Owner set to rwaldron
  • Status changed from new to assigned

Confirmed.

comment:5 Changed 22 months ago by rwaldron

  • Status changed from assigned to closed
  • Resolution set to notabug

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

comment:6 Changed 22 months ago by dmethvin

  • Priority changed from undecided to low
  • Component changed from unfiled to event

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 22 months ago by dmethvin

  • Status changed from closed to reopened
  • Resolution notabug deleted

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 22 months 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 22 months ago by c4605 (previous) (diff)

comment:9 in reply to: ↑ description Changed 22 months 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 22 months ago by Dave Methvin

  • Status changed from reopened to closed
  • Resolution set to fixed

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 22 months 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.