Skip to content

Error "Uncaught TypeError: Cannot read property 'update' of undefined" when using firebase-document #110

@mm-gmbd

Description

@mm-gmbd

This is mentioned in issue #31, but it looks like that issue has gone cold and the title is a little misleading, so I'm opening this issue for the following error:

Error "Uncaught TypeError: Cannot read property 'update' of undefined"

After performing a fresh clone of my project repository, I'm now receiving this issue. I was on firebase-element v1.0.10, and after the clone I'm on the latest v.1.0.12, but nothing in the change logs would seem to affect this behavior... regardless, I'm receiving the error.

I'm at a loss after some debugging... the code is as follows:

<firebase-document
  location="[[_computeUserLocation(location, _user)]]"
  data={{userData}}>
</firebase-document>

The property userData was originally set to an empty object in the element's properties:

properties: {
  ...,
  userData: {
    type: Object,
    value: function(){ return {} }
  }
}

But, removing the value, or removing the property entirely has no effect.

I've added the following logs to firebase-document:

_localDataChanged: function(change) {
  var pathFragments = change.path.split('.');

  console.log("change",change);
  console.log("this.location: ",this.location)
  console.log("this.query: ",this.query)

  if (pathFragments.length === 1) {
    // this._updateRemoteDocument();
    return;
  }

  this._setRemoteDocumentChild(
    pathFragments[1],
    change.base[pathFragments[1]]
  );
},

> change Object {path: "data", value: Object, base: Object } //both value and base are empty objects
> this.location: undefined
> this.query: undefined

The last line of output is the issue, because _updateRemoteDocument is defined as follows:

_updateRemoteDocument: function() {
  this._log('Updating remote document');
  this.query.update(this.dataAsObject); //query does not exist!!!
},

But, considering "query" is a property of firebase-document, I'm confused as to how it is simply undefined...

This raises another question for me as well, say I'd like to simply get data using firebase-document at a location that I have both read and write access to. With firebase-document, I provide a property to bind data to, but this always attempts to write to the location supplied first... how can just a pure read be accomplished??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions