git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c272f5f
)
Put the split to get the list of promise methods out of the promise method itself...
author
jaubourg
<j@ubourg.net>
Sun, 16 Jan 2011 17:33:32 +0000
(18:33 +0100)
committer
jaubourg
<j@ubourg.net>
Sun, 16 Jan 2011 17:33:32 +0000
(18:33 +0100)
src/core.js
patch
|
blob
|
history
diff --git
a/src/core.js
b/src/core.js
index
25ef22d
..
fbf6491
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-63,6
+63,9
@@
var jQuery = function( selector, context ) {
// The deferred used on DOM ready
readyList,
// The deferred used on DOM ready
readyList,
+ // Promise methods
+ promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
+
// The ready event handler
DOMContentLoaded,
// The ready event handler
DOMContentLoaded,
@@
-914,16
+917,18
@@
jQuery.extend({
isRejected: failDeferred.isResolved,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
isRejected: failDeferred.isResolved,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
- promise: function( obj ) {
+ // (i is used internally)
+ promise: function( obj , i ) {
if ( obj == null ) {
if ( promise ) {
return promise;
}
promise = obj = {};
}
if ( obj == null ) {
if ( promise ) {
return promise;
}
promise = obj = {};
}
- jQuery.each( "then done fail isResolved isRejected promise".split( " " ) , function( _ , method ) {
- obj[ method ] = deferred[ method ];
- });
+ i = promiseMethods.length;
+ while( i-- ) {
+ obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
+ }
return obj;
}
return obj;
}