File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 126126
127127 var promise = new AV . Promise ( ) ;
128128
129- var resolveOne = function ( ) {
129+ var resolveOne = function ( i ) {
130130 total = total - 1 ;
131+ if ( hadError && ! promise . _rejected && isAll ) {
132+ return promise . reject ( promise , errors [ i ] ) ;
133+ }
134+
131135 if ( total === 0 ) {
132- if ( hadError ) {
136+ if ( hadError && ! isAll ) {
133137 promise . reject ( errors ) ;
134138 } else {
135139 if ( isAll ) {
145149 if ( AV . Promise . is ( object ) ) {
146150 object . then ( function ( result ) {
147151 results [ i ] = result ;
148- resolveOne ( ) ;
152+ resolveOne ( i ) ;
149153 } , function ( error ) {
150154 errors [ i ] = error ;
151155 hadError = true ;
152- resolveOne ( ) ;
156+ resolveOne ( i ) ;
153157 } ) ;
154158 } else {
155159 results [ i ] = object ;
156- resolveOne ( ) ;
160+ resolveOne ( i ) ;
157161 }
158162 } ) ;
159163
253257
254258 /**
255259 * Just like AV.Promise.when, but it calls resolveCallbck function
256- * with one results array.
260+ * with one results array and calls rejectCallback function as soon as one
261+ * of promises rejects.
257262 * @see AV.Promise.when
258263 */
259264 AV . Promise . all = function ( promises ) {
You can’t perform that action at this time.
0 commit comments