firebase-element icon indicating copy to clipboard operation
firebase-element copied to clipboard

Error when binding data to an empty object

Open mm-gmbd opened this issue 9 years ago • 0 comments
trafficstars

I stumbled across this in an application I'm working on. In my application, I have an array that looks like the following (let's call it data):

properties: {
  data: {
    type: Array,
    value: function() {
      return [
        {
          location: "https://a-firebase.firebaseio.com/path/to/A",
          values: {}
        },
        {
          location: "https://a-firebase.firebaseio.com/path/to/B",
          values: {}
        }
      ]
    }
  }
}

I'm using this data structure to store data from multiple queries in a single object, in this case, data. I accomplish this by the following:

<template is="dom-bind" items="{{data}}" as="d">
  <firebase-document
    location="[[d.location]]"
    data="{{d.values}}"
</template>

However, the way this is laid out currently produces the following error:

Uncaught TypeError: Cannot read property 'update' of undefined

This has something to do with the fact that the values property for both elements in data is already defined.

If I remove values:

properties: {
  data: {
    type: Array,
    value: function() {
      return [
        {
          location: "https://a-firebase.firebaseio.com/path/to/A",
        },
        {
          location: "https://a-firebase.firebaseio.com/path/to/B",
        }
      ]
    }
  }
}

then I receive no error and the data from each query ends up happily at data[index].values for each element in the array.

I haven't seen this documented anywhere, so I tend to think this is a bug.

mm-gmbd avatar Jan 27 '16 20:01 mm-gmbd