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

Commit 250b5fa

Browse files
committed
merge from master
2 parents 0649a94 + adfdd00 commit 250b5fa

16 files changed

+138
-36
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ before_script:
1818
- phantomjs --version
1919
script:
2020
- sh ./tests/travis.sh
21+
after_script:
22+
- cat ./tests/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
2123
env:
2224
global:
2325
- secure: mGHp1rQI11OvbBQn3PnBT5kuyo26gFl8U+nNq0Ot4opgSBX9JaHqS8Dx63uALWWU9qjy08/Mn68t/sKhayH1+XrPDIenOy/XEkkSAG60qAAowD9dRo3WaIMSOcWWYDeqdZOAWZ3LiXvjLO4Swagz5ejz7UtY/ws4CcTi2n/fp7c=

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = function(grunt) {
7272
jshint : {
7373
options : {
7474
jshintrc: '.jshintrc',
75-
ignores: ['src/polyfills.js'],
75+
ignores: ['src/lib/polyfills.js']
7676
},
7777
all : ['src/**/*.js']
7878
},

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# AngularFire
33

44
[![Build Status](https://travis-ci.org/firebase/angularfire.svg?branch=master)](https://travis-ci.org/firebase/angularfire)
5+
[![Coverage Status](https://img.shields.io/coveralls/firebase/angularfire.svg)](https://coveralls.io/r/firebase/angularfire)
56
[![Version](https://badge.fury.io/gh/firebase%2Fangularfire.svg)](http://badge.fury.io/gh/firebase%2Fangularfire)
67

78
AngularFire is the officially supported [AngularJS](http://angularjs.org/) binding for

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"firebase": "1.0.x"
3535
},
3636
"devDependencies": {
37+
"coveralls": "^2.11.1",
3738
"grunt": "~0.4.1",
3839
"grunt-cli": "^0.1.13",
3940
"grunt-contrib-concat": "^0.4.0",
@@ -45,16 +46,16 @@
4546
"grunt-notify": "~0.2.7",
4647
"grunt-protractor-runner": "^1.0.0",
4748
"grunt-shell-spawn": "^0.3.0",
49+
"jasmine-spec-reporter": "^0.4.0",
4850
"karma": "~0.12.0",
51+
"karma-chrome-launcher": "^0.1.4",
52+
"karma-coverage": "^0.2.4",
53+
"karma-failed-reporter": "0.0.2",
4954
"karma-jasmine": "~0.2.0",
5055
"karma-phantomjs-launcher": "~0.1.0",
5156
"karma-sauce-launcher": "~0.2.9",
52-
"load-grunt-tasks": "~0.2.0",
53-
"protractor": "^1.0.0",
54-
"karma-coverage": "^0.2.4",
55-
"karma-failed-reporter": "0.0.2",
56-
"jasmine-spec-reporter": "^0.4.0",
5757
"karma-spec-reporter": "0.0.13",
58-
"karma-chrome-launcher": "^0.1.4"
58+
"load-grunt-tasks": "~0.2.0",
59+
"protractor": "^1.0.0"
5960
}
6061
}

src/FirebaseArray.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@
265265
}
266266
rec.$id = snap.name();
267267
rec.$priority = snap.getPriority();
268+
$firebaseUtils.applyDefaults(rec, this.$$defaults);
268269

269270
// add it to array and send notifications
270271
this._process('child_added', rec, prevChild);
@@ -295,6 +296,7 @@
295296
if( angular.isObject(rec) ) {
296297
// apply changes to the record
297298
var changed = $firebaseUtils.updateRec(rec, snap);
299+
$firebaseUtils.applyDefaults(rec, this.$$defaults);
298300
if( changed ) {
299301
this._process('child_changed', rec);
300302
}

src/FirebaseObject.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,17 @@
4848
listeners: []
4949
};
5050

51+
// this bit of magic makes $$conf non-enumerable and non-configurable
52+
// and non-writable (its properties are still writable but the ref cannot be replaced)
53+
// we declare it above so the IDE can relax
54+
Object.defineProperty(this, '$$conf', {
55+
value: this.$$conf
56+
});
57+
5158
this.$id = $firebase.$ref().ref().name();
5259
this.$priority = null;
60+
61+
$firebaseUtils.applyDefaults(this, this.$$defaults);
5362
}
5463

5564
FirebaseObject.prototype = {
@@ -168,6 +177,7 @@
168177
$$updated: function (snap) {
169178
// applies new data to this object
170179
var changed = $firebaseUtils.updateRec(this, snap);
180+
$firebaseUtils.applyDefaults(this, this.$$defaults);
171181
if( changed ) {
172182
// notifies $watch listeners and
173183
// updates $scope if bound to a variable
@@ -208,6 +218,15 @@
208218
angular.forEach(list, function (parts) {
209219
parts[0].call(parts[1], {event: 'value', key: self.$id});
210220
});
221+
},
222+
223+
/**
224+
* Overrides how Angular.forEach iterates records on this object so that only
225+
* fields stored in Firebase are part of the iteration. To include meta fields like
226+
* $id and $priority in the iteration, utilize for(key in obj) instead.
227+
*/
228+
forEach: function(iterator, context) {
229+
return $firebaseUtils.each(this, iterator, context);
211230
}
212231
};
213232

src/firebase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
throw new Error('config.arrayFactory must be a valid function');
171171
}
172172
if (!angular.isFunction(cnf.objectFactory)) {
173-
throw new Error('config.arrayFactory must be a valid function');
173+
throw new Error('config.objectFactory must be a valid function');
174174
}
175175
}
176176
};

src/firebaseSimpleLogin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* istanbul ignore next */
12
(function() {
23
'use strict';
34
var AngularFireAuth;
File renamed without changes.

src/utils.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
},
239239

240240
compile: function(fn) {
241-
return $timeout(fn||function() {}, wait||0);
241+
return $timeout(fn||function() {});
242242
},
243243

244244
deepCopy: function(obj) {
@@ -298,17 +298,20 @@
298298
angular.extend(rec, data);
299299
rec.$priority = snap.getPriority();
300300

301-
if( angular.isObject(rec.$$defaults) ) {
302-
angular.forEach(rec.$$defaults, function(v,k) {
301+
return !angular.equals(oldData, rec) ||
302+
oldData.$value !== rec.$value ||
303+
oldData.$priority !== rec.$priority;
304+
},
305+
306+
applyDefaults: function(rec, defaults) {
307+
if( angular.isObject(defaults) ) {
308+
angular.forEach(defaults, function(v,k) {
303309
if( !rec.hasOwnProperty(k) ) {
304310
rec[k] = v;
305311
}
306312
});
307313
}
308-
309-
return !angular.equals(oldData, rec) ||
310-
oldData.$value !== rec.$value ||
311-
oldData.$priority !== rec.$priority;
314+
return rec;
312315
},
313316

314317
dataKeys: function(obj) {
@@ -320,13 +323,22 @@
320323
},
321324

322325
each: function(obj, iterator, context) {
323-
angular.forEach(obj, function(v,k) {
324-
var c = k.charAt(0);
325-
//todo does _ belong here? it's a valid char in firebase keys
326-
if( c !== '_' && c !== '$' && c !== '.' ) {
327-
iterator.call(context, v, k, obj);
326+
if(angular.isObject(obj)) {
327+
for (var k in obj) {
328+
if (obj.hasOwnProperty(k)) {
329+
var c = k.charAt(0);
330+
if( c !== '_' && c !== '$' && c !== '.' ) {
331+
iterator.call(context, obj[k], k, obj);
332+
}
333+
}
328334
}
329-
});
335+
}
336+
else if(angular.isArray(obj)) {
337+
for(var i = 0, len = obj.length; i < len; i++) {
338+
iterator.call(context, obj[i], i, obj);
339+
}
340+
}
341+
return obj;
330342
},
331343

332344
/**

0 commit comments

Comments
 (0)