#13517 closed bug (fixed)
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: |
Description
Try this page and open your web inspector console: http://jsfiddle.net/zkctt/
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'); }); cb.fire();
Change History (5)
comment:1 Changed 10 years ago by
Owner: | set to anonymous |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
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.
comment:3 Changed 10 years ago by
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; },
comment:4 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | pending → closed |
Properly resets firingLength when emptying the list. Fixes #13517
Changeset: a14a31727feed23c4ba4e4948700b7719ce219aa
comment:5 Changed 10 years ago by
Properly resets firingLength when emptying the list. Fixes #13517
Changeset: 0618710913f41d7a7f4c095f0edda035e65a887d
Why?