Skip to main content

Bug Tracker

Side navigation

#15213 closed bug (migrated)

Opened August 18, 2014 01:45PM UTC

Closed October 21, 2014 01:01AM UTC

Calling .empty() on a disabled callbacks object re-enables it

Reported by: TheDistantSea Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:
Description

Earlier today I answered this StackOverflow question, wherein this behavior is shown:

var c = $.Callbacks();
var f = /* some function */;
c.disable();
c.empty();
c.add(f);
c.disabled(); // of course true
c.fire(); // invokes f!

This behavior occurs in all versions of jQuery I tested (latest 1.9, 1.10, 1.11, 2.0, 2.1) -- here's a fiddle to easily reproduce it.

The problem is that .disable() relies on setting internal variables of the callbacks object to undefined, and while most other methods such as .add() test and this condition and abort if true, .empty() itself does not. Instead it resets ''some'' of those variables, which causes the abort test in the other methods to erroneously pass and ultimately for callbacks to be added to and invoked by a disabled object.

Attachments (0)
Change History (2)

Changed August 18, 2014 01:56PM UTC by TheDistantSea comment:1

Changed October 21, 2014 01:01AM UTC by m_gol comment:2

resolution: → migrated
status: newclosed