Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc7477f

Browse files
committed
Callbacks: Don't abort execution on .lock()
Fixesgh-1990Closesgh-1991
1 parentf5a8c64 commitfc7477f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎src/callbacks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jQuery.Callbacks = function( options ) {
190190
lock:function(){
191191
stack=undefined;
192192
locked=true;
193-
if(!memory){
193+
if(!memory&&!firing){
194194
self.disable();
195195
}
196196
returnthis;

‎test/unit/callbacks.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
6565

6666
test("jQuery.Callbacks( "+showFlags(flags)+" ) - "+filterLabel,function(){
6767

68-
expect(28);
68+
expect(29);
6969

7070
varcblist,
7171
results=resultString.split(/\s+/);
@@ -94,7 +94,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
9494
strictEqual(cblist.disabled(),true,".disabled() becomes true");
9595
strictEqual(cblist.locked(),true,"disabling locks");
9696

97-
//#13517 -Emptying while firing
97+
// Emptying while firing (#13517)
9898
cblist=jQuery.Callbacks(flags);
9999
cblist.add(cblist.empty);
100100
cblist.add(function(){
@@ -164,6 +164,16 @@ jQuery.each( tests, function( strFlags, resultString ) {
164164
strictEqual(output,"X","Lock early");
165165
strictEqual(cblist.locked(),true,"Locking reflected in accessor");
166166

167+
// Locking while firing (gh-1990)
168+
output="X";
169+
cblist=jQuery.Callbacks(flags);
170+
cblist.add(cblist.lock);
171+
cblist.add(function(str){
172+
output+=str;
173+
});
174+
cblist.fire("A");
175+
strictEqual(output,"XA","Locking doesn't abort execution (gh-1990)");
176+
167177
// Ordering
168178
output="X";
169179
cblist=jQuery.Callbacks(flags);
@@ -331,8 +341,6 @@ test( "jQuery.Callbacks.has", function() {
331341
strictEqual(cb.has(),true,"Check if unique list has callback function(s) attached");
332342
cb.lock();
333343
strictEqual(cb.has(),false,"locked() list is empty and returns false");
334-
335-
336344
});
337345

338346
test("jQuery.Callbacks() - adding a string doesn't cause a stack overflow",function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp