Skip to main content

Bug Tracker

Side navigation

#13517 closed bug (fixed)

Opened February 25, 2013 04:51PM UTC

Closed February 27, 2013 03:14PM UTC

Last modified February 27, 2013 03:18PM UTC

Adding a callback calling empty method to $.Callbacks object makes error thrown on fire

Reported by: anonymous Owned by: anonymous
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Try this page and open your web inspector console:

var cb = $.Callbacks();

cb.add(cb.empty); // empty method call in callback cause error on next callback called
cb.add(function(){ console.log('not reached and throw error'); });;
Attachments (0)
Change History (5)

Changed February 25, 2013 05:01PM UTC by dmethvin comment:1

owner: → anonymous
status: newpending


Changed February 25, 2013 05:29PM UTC by jaubourg comment:2

Dang, we probably don't test for the existing of the array inside of fire. I cannot test right now but I'll check when I'm back home.

Changed February 26, 2013 04:14PM UTC by kakusuke comment:3

I'm reporter.

This bug comes from carelessness of $.Callbacks object status.

At src/callbacks.js:147 on master branch, we should take care of "firing", "firingLength" and "firingIndex" variables like remove method.

According to my sense, the result of empty method call should be same as the result of appling remove method for each registered callbacks,

so I think "firingLength" and "firingIndex" shoud be initialized with zero, like following:

empty: function() {
	list = [];
	if ( firing ) {
		firingLength = firingIndex = 0;
	return this;

Changed February 27, 2013 03:14PM UTC by jaubourg comment:4

resolution: → fixed
status: pendingclosed

Properly resets firingLength when emptying the list. Fixes #13517

Changeset: a14a31727feed23c4ba4e4948700b7719ce219aa

Changed February 27, 2013 03:18PM UTC by jaubourg comment:5

Properly resets firingLength when emptying the list. Fixes #13517

Changeset: 0618710913f41d7a7f4c095f0edda035e65a887d