Skip to content

Commit bec51c1

Browse files
committed
tests for object binding wip
1 parent 5ac6605 commit bec51c1

File tree

2 files changed

+404
-360
lines changed

2 files changed

+404
-360
lines changed

src/vuefire.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ function indexForKey (array, key) {
4949
* @param {object} source
5050
*/
5151
function bind (vm, key, source) {
52-
if (!isObject(source)) {
53-
throw new Error('VueFire: invalid Firebase binding source.')
54-
}
5552
var asObject = false
5653
var cancelCallback = null
5754
// check { source, asArray, cancelCallback } syntax
58-
if (isObject(source.source)) {
55+
if (isObject(source) && source.hasOwnProperty('source')) {
5956
asObject = source.asObject
6057
cancelCallback = source.cancelCallback
6158
source = source.source
6259
}
60+
if (!isObject(source)) {
61+
throw new Error('VueFire: invalid Firebase binding source.')
62+
}
6363
// get the original ref for possible queries
6464
var ref = source
6565
if (typeof source.ref === 'function') {
@@ -128,7 +128,7 @@ function bindAsArray (vm, key, source, cancelCallback) {
128128
function bindAsObject (vm, key, source, cancelCallback) {
129129
Vue.util.defineReactive(vm, key, {})
130130
var cb = source.on('value', function (snapshot) {
131-
vm[key] = snapshot.val()
131+
vm[key] = createRecord(snapshot)
132132
}, cancelCallback)
133133
vm._firebaseListeners[key] = { value: cb }
134134
}

0 commit comments

Comments
 (0)