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

Commit 83b92cf

Browse files
author
Jacob Wenger
committed
Merge pull request #390 from firebase/release_0.8.1_defaults
Release 0.8.1 defaults
2 parents 021ed45 + 4fda3da commit 83b92cf

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

dist/angularfire.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,14 @@ if ( typeof Object.getPrototypeOf !== "function" ) {
17231723
angular.extend(rec, data);
17241724
rec.$priority = snap.getPriority();
17251725

1726+
if( angular.isObject(rec.$$defaults) ) {
1727+
angular.forEach(rec.$$defaults, function(v,k) {
1728+
if( !rec.hasOwnProperty(k) ) {
1729+
rec[k] = v;
1730+
}
1731+
});
1732+
}
1733+
17261734
return !angular.equals(oldData, rec) ||
17271735
oldData.$value !== rec.$value ||
17281736
oldData.$priority !== rec.$priority;

dist/angularfire.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@
214214
angular.extend(rec, data);
215215
rec.$priority = snap.getPriority();
216216

217+
if( angular.isObject(rec.$$defaults) ) {
218+
angular.forEach(rec.$$defaults, function(v,k) {
219+
if( !rec.hasOwnProperty(k) ) {
220+
rec[k] = v;
221+
}
222+
});
223+
}
224+
217225
return !angular.equals(oldData, rec) ||
218226
oldData.$value !== rec.$value ||
219227
oldData.$priority !== rec.$priority;

tests/unit/utils.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ describe('$firebaseUtils', function () {
6262
expect($utils.updateRec(rec, testutils.snap({foo: 'bar'}, 'foo'))).toBe(false);
6363
});
6464

65-
// save this for the next PR
66-
xit('should add $$defaults if they exist', function() {
65+
it('should add $$defaults if they exist', function() {
6766
var rec = { foo: 'bar' };
68-
rec.$$defaults = { foo: 'not_applied', bar: 'foo' };
67+
rec.$$defaults = { baz: 'not_applied', bar: 'foo' };
6968
$utils.updateRec(rec, testutils.snap({baz: 'bar'}));
70-
expect(rec).toEqual(jasmine.objectContaining({foo: 'bar', bar: 'foo', baz: 'bar', $$defaults: { foo: 'not_applied', bar: 'foo' }}));
69+
expect(rec).toEqual(jasmine.objectContaining({bar: 'foo', baz: 'bar'}));
7170
});
7271

7372
it('should apply changes to record', function() {

0 commit comments

Comments
 (0)