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
5237b096
Commit
5237b096
authored
Dec 25, 2010
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed custom method in isDeferred and when.
parent
846c52d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
31 deletions
+7
-31
core.js
src/core.js
+4
-9
core.js
test/unit/core.js
+3
-22
No files found.
src/core.js
View file @
5237b096
...
@@ -936,20 +936,15 @@ jQuery.extend({
...
@@ -936,20 +936,15 @@ jQuery.extend({
},
},
// Check if an object is a deferred
// Check if an object is a deferred
isDeferred
:
function
(
object
,
method
)
{
isDeferred
:
function
(
object
)
{
method
=
method
||
"then"
;
return
!!
(
object
&&
object
.
then
&&
object
.
then
.
_
===
deferredMarker
);
return
!!
(
object
&&
object
[
method
]
&&
object
[
method
].
_
===
deferredMarker
);
},
},
// Deferred helper
// Deferred helper
when
:
function
(
object
,
method
)
{
when
:
function
(
object
)
{
method
=
method
||
"then"
;
object
=
jQuery
.
isDeferred
(
object
)
?
object
=
jQuery
.
isDeferred
(
object
,
method
)
?
object
:
object
:
jQuery
.
Deferred
().
resolve
(
object
);
jQuery
.
Deferred
().
resolve
(
object
);
object
.
fail
=
object
.
fail
||
function
()
{
return
this
;
};
object
[
method
]
=
object
[
method
]
||
object
.
then
;
object
.
then
=
object
.
then
||
object
[
method
];
return
object
;
return
object
;
},
},
...
...
test/unit/core.js
View file @
5237b096
...
@@ -1022,7 +1022,7 @@ test("jQuery.Deferred()", function() {
...
@@ -1022,7 +1022,7 @@ test("jQuery.Deferred()", function() {
test
(
"jQuery.isDeferred()"
,
function
()
{
test
(
"jQuery.isDeferred()"
,
function
()
{
expect
(
1
1
);
expect
(
1
0
);
var
object1
=
{
then
:
function
()
{
return
this
;
}
},
var
object1
=
{
then
:
function
()
{
return
this
;
}
},
object2
=
{
then
:
function
()
{
return
this
;
}
};
object2
=
{
then
:
function
()
{
return
this
;
}
};
...
@@ -1047,14 +1047,13 @@ test("jQuery.isDeferred()", function() {
...
@@ -1047,14 +1047,13 @@ test("jQuery.isDeferred()", function() {
object1
=
{
custom
:
jQuery
.
_Deferred
().
then
};
object1
=
{
custom
:
jQuery
.
_Deferred
().
then
};
ok
(
!
jQuery
.
isDeferred
(
object1
)
,
"custom method name not found automagically"
);
ok
(
!
jQuery
.
isDeferred
(
object1
)
,
"custom method name not found automagically"
);
ok
(
jQuery
.
isDeferred
(
object1
,
"custom"
)
,
"custom method name"
);
});
});
test
(
"jQuery.when()"
,
function
()
{
test
(
"jQuery.when()"
,
function
()
{
expect
(
5
);
expect
(
2
);
var
cache
,
i
,
deferred
=
{
done
:
jQuery
.
Deferred
().
resolve
(
1
).
then
}
;
var
cache
,
i
;
for
(
i
=
1
;
i
<
3
;
i
++
)
{
for
(
i
=
1
;
i
<
3
;
i
++
)
{
jQuery
.
when
(
cache
||
jQuery
.
Deferred
(
function
()
{
jQuery
.
when
(
cache
||
jQuery
.
Deferred
(
function
()
{
...
@@ -1066,22 +1065,4 @@ test("jQuery.when()", function() {
...
@@ -1066,22 +1065,4 @@ test("jQuery.when()", function() {
ok
(
false
,
"Fail called"
);
ok
(
false
,
"Fail called"
);
});
});
}
}
cache
=
0
;
for
(
i
=
1
;
i
<
3
;
i
++
)
{
jQuery
.
when
(
cache
||
deferred
,
"done"
).
done
(
function
(
value
)
{
strictEqual
(
value
,
1
,
"Custom method: resolved"
+
(
i
>
1
?
" only once"
:
""
)
);
cache
=
value
;
}).
fail
(
function
()
{
ok
(
false
,
"Custom method: fail called"
);
});
}
stop
();
jQuery
.
when
(
jQuery
(
document
)
,
"ready"
).
then
(
function
(
test
)
{
strictEqual
(
test
,
jQuery
,
"jQuery.fn.ready recognized as a deferred"
);
start
();
});
});
});
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