Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit 0b4f8e9

Browse files
committed
Move up assertArray() check.
Passing a non-array was throwing an error about batching. The error message provided by assertArray is more likely to help users isolate their mistake.
1 parent eb41f32 commit 0b4f8e9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/firebase.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,16 @@
248248
}
249249
}
250250
});
251+
252+
assertArray(array);
253+
251254
var error = batch(array.$$error, array);
252255
var resolve = batch(_resolveFn);
253256

254257
var self = this;
255258
self.isDestroyed = false;
256259
self.getArray = function() { return array; };
257260

258-
assertArray(array);
259261
init();
260262
}
261263

tests/unit/firebase.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ describe('$firebase', function () {
478478
expect(function() {
479479
function fn() { return {}; }
480480
$firebase(new Firebase('Mock://').child('data'), {arrayFactory: fn}).$asArray();
481-
}).toThrowError(Error);
481+
}).toThrow(new Error('arrayFactory must return a valid array that passes ' +
482+
'angular.isArray and Array.isArray, but received "[object Object]"'));
482483
});
483484

484485
it('should contain data in ref() after load', function() {

0 commit comments

Comments
 (0)