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
fc7477f4
Commit
fc7477f4
authored
Jan 04, 2015
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Callbacks: Don't abort execution on .lock()
Fixes gh-1990 Closes gh-1991
parent
f5a8c649
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
callbacks.js
src/callbacks.js
+1
-1
callbacks.js
test/unit/callbacks.js
+12
-4
No files found.
src/callbacks.js
View file @
fc7477f4
...
...
@@ -190,7 +190,7 @@ jQuery.Callbacks = function( options ) {
lock
:
function
()
{
stack
=
undefined
;
locked
=
true
;
if
(
!
memory
)
{
if
(
!
memory
&&
!
firing
)
{
self
.
disable
();
}
return
this
;
...
...
test/unit/callbacks.js
View file @
fc7477f4
...
...
@@ -65,7 +65,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
test
(
"jQuery.Callbacks( "
+
showFlags
(
flags
)
+
" ) - "
+
filterLabel
,
function
()
{
expect
(
2
8
);
expect
(
2
9
);
var
cblist
,
results
=
resultString
.
split
(
/
\s
+/
);
...
...
@@ -94,7 +94,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
strictEqual
(
cblist
.
disabled
(),
true
,
".disabled() becomes true"
);
strictEqual
(
cblist
.
locked
(),
true
,
"disabling locks"
);
//
#13517 - Emptying while firing
//
Emptying while firing (#13517)
cblist
=
jQuery
.
Callbacks
(
flags
);
cblist
.
add
(
cblist
.
empty
);
cblist
.
add
(
function
()
{
...
...
@@ -164,6 +164,16 @@ jQuery.each( tests, function( strFlags, resultString ) {
strictEqual
(
output
,
"X"
,
"Lock early"
);
strictEqual
(
cblist
.
locked
(),
true
,
"Locking reflected in accessor"
);
// Locking while firing (gh-1990)
output
=
"X"
;
cblist
=
jQuery
.
Callbacks
(
flags
);
cblist
.
add
(
cblist
.
lock
);
cblist
.
add
(
function
(
str
)
{
output
+=
str
;
});
cblist
.
fire
(
"A"
);
strictEqual
(
output
,
"XA"
,
"Locking doesn't abort execution (gh-1990)"
);
// Ordering
output
=
"X"
;
cblist
=
jQuery
.
Callbacks
(
flags
);
...
...
@@ -331,8 +341,6 @@ test( "jQuery.Callbacks.has", function() {
strictEqual
(
cb
.
has
(),
true
,
"Check if unique list has callback function(s) attached"
);
cb
.
lock
();
strictEqual
(
cb
.
has
(),
false
,
"locked() list is empty and returns false"
);
});
test
(
"jQuery.Callbacks() - adding a string doesn't cause a stack overflow"
,
function
()
{
...
...
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