Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
245f5a24
Commit
245f5a24
authored
Apr 25, 2012
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regression: makes sure that all instances of a callback are removed. Unit test added.
parent
97210d4e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
callbacks.js
src/callbacks.js
+2
-2
callbacks.js
test/unit/callbacks.js
+15
-0
No files found.
src/callbacks.js
View file @
245f5a24
...
...
@@ -119,8 +119,8 @@ jQuery.Callbacks = function( options ) {
// Remove a callback from the list
remove
:
function
()
{
if
(
list
)
{
jQuery
.
each
(
arguments
,
function
(
index
,
arg
)
{
if
(
(
index
=
jQuery
.
inArray
(
arg
,
list
)
)
>
-
1
)
{
jQuery
.
each
(
arguments
,
function
(
_
,
arg
,
index
)
{
while
(
(
index
=
jQuery
.
inArray
(
arg
,
list
,
index
||
0
)
)
>
-
1
)
{
list
.
splice
(
index
,
1
);
// Handle firing indexes
if
(
firing
)
{
...
...
test/unit/callbacks.js
View file @
245f5a24
...
...
@@ -235,3 +235,18 @@ test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
strictEqual
(
hello
,
"hello"
,
"arguments are copied internally"
);
});
});
test
(
"jQuery.Callbacks.remove - should remove all instances"
,
function
()
{
expect
(
1
);
var
cb
=
jQuery
.
Callbacks
();
function
fn
()
{
ok
(
false
,
"function wasn't removed"
);
}
cb
.
add
(
fn
,
fn
,
function
()
{
ok
(
true
,
"end of test"
);
}).
remove
(
fn
).
fire
();
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment