javascript - Is this a bug of jQuery Callback? -
i looking source code of jquery 1.8.1, , found there maybe wrong jquery:
first, disable callback using disable(), call empty(), add function using add(), call fire(), api explains disable() :
disable callback list doing more
the last call fire() should output nothing, actually, output '2' if disable() not called;
var = $.callbacks(); a.add(function(){console.log('1');}); a.disable(); a.disabled(); //true a.empty(); a.add(function(){console.log('2');}); a.fire(); //2 so jquery bug?
it's not bug in jquery, @ least not inside disable. calling disable indeed make callbacks object inert practical purposes.
your code sample calls empty, re-initializes callbacks object , in doing returns in usable state. that might bug, since empty not documented this.
removing call empty results in expected behavior.
Comments
Post a Comment