@@ -70,7 +70,7 @@ jQuery.Callbacks = function( flags, filter ) {
70
70
firingLength ,
71
71
// Index of currently firing callback (modified by remove if needed)
72
72
firingIndex ,
73
- // Add a list of callbacks to the list
73
+ // Add one or several callbacks to the list
74
74
add = function ( args ) {
75
75
var i ,
76
76
length ,
@@ -87,9 +87,9 @@ jQuery.Callbacks = function( flags, filter ) {
87
87
// If we have to relocate, we remove the callback
88
88
// if it already exists
89
89
if ( flags . relocate ) {
90
- object . remove ( elem ) ;
90
+ self . remove ( elem ) ;
91
91
// Skip if we're in unique mode and callback is already in
92
- } else if ( flags . unique && object . has ( elem ) ) {
92
+ } else if ( flags . unique && self . has ( elem ) ) {
93
93
continue ;
94
94
}
95
95
// Get the filtered function if needs be
@@ -100,6 +100,7 @@ jQuery.Callbacks = function( flags, filter ) {
100
100
}
101
101
}
102
102
} ,
103
+ // Fire callbacks
103
104
fire = function ( context , args ) {
104
105
args = args || [ ] ;
105
106
memory = ! flags . memory || [ context , args ] ;
@@ -118,16 +119,17 @@ jQuery.Callbacks = function( flags, filter ) {
118
119
if ( ! flags . once ) {
119
120
if ( stack && stack . length ) {
120
121
memory = stack . shift ( ) ;
121
- object . fireWith ( memory [ 0 ] , memory [ 1 ] ) ;
122
+ self . fireWith ( memory [ 0 ] , memory [ 1 ] ) ;
122
123
}
123
124
} else if ( memory === true ) {
124
- object . disable ( ) ;
125
+ self . disable ( ) ;
125
126
} else {
126
127
list = [ ] ;
127
128
}
128
129
}
129
130
} ,
130
- object = {
131
+ // Actual Callbacks object
132
+ self = {
131
133
// Add a callback or a collection of callbacks to the list
132
134
add : function ( ) {
133
135
if ( list ) {
@@ -150,25 +152,30 @@ jQuery.Callbacks = function( flags, filter ) {
150
152
return this ;
151
153
} ,
152
154
// Remove a callback from the list
153
- remove : function ( fn ) {
155
+ remove : function ( ) {
154
156
if ( list ) {
155
- for ( var i = 0 ; i < list . length ; i ++ ) {
156
- if ( fn === list [ i ] [ 0 ] ) {
157
- // Handle firingIndex and firingLength
158
- if ( firing ) {
159
- if ( i <= firingLength ) {
160
- firingLength -- ;
161
- if ( i <= firingIndex ) {
162
- firingIndex -- ;
157
+ var args = arguments ,
158
+ argIndex = 0 ,
159
+ argLength = args . length ;
160
+ for ( ; argIndex < argLength ; argIndex ++ ) {
161
+ for ( var i = 0 ; i < list . length ; i ++ ) {
162
+ if ( args [ argIndex ] === list [ i ] [ 0 ] ) {
163
+ // Handle firingIndex and firingLength
164
+ if ( firing ) {
165
+ if ( i <= firingLength ) {
166
+ firingLength -- ;
167
+ if ( i <= firingIndex ) {
168
+ firingIndex -- ;
169
+ }
163
170
}
164
171
}
165
- }
166
- // Remove the element
167
- list . splice ( i -- , 1 ) ;
168
- // If we have some unicity property then
169
- // we only need to do this once
170
- if ( flags . unique || flags . relocate ) {
171
- break ;
172
+ // Remove the element
173
+ list . splice ( i -- , 1 ) ;
174
+ // If we have some unicity property then
175
+ // we only need to do this once
176
+ if ( flags . unique || flags . relocate ) {
177
+ break ;
178
+ }
172
179
}
173
180
}
174
181
}
@@ -206,7 +213,7 @@ jQuery.Callbacks = function( flags, filter ) {
206
213
lock : function ( ) {
207
214
stack = undefined ;
208
215
if ( ! memory || memory === true ) {
209
- object . disable ( ) ;
216
+ self . disable ( ) ;
210
217
}
211
218
return this ;
212
219
} ,
@@ -229,7 +236,7 @@ jQuery.Callbacks = function( flags, filter ) {
229
236
} ,
230
237
// Call all the callbacks with the given arguments
231
238
fire : function ( ) {
232
- object . fireWith ( this , arguments ) ;
239
+ self . fireWith ( this , arguments ) ;
233
240
return this ;
234
241
} ,
235
242
// To know if the callbacks have already been called at least once
@@ -238,7 +245,7 @@ jQuery.Callbacks = function( flags, filter ) {
238
245
}
239
246
} ;
240
247
241
- return object ;
248
+ return self ;
242
249
} ;
243
250
244
251
} ) ( jQuery ) ;
0 commit comments