Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mm-gmbd opened this issue Feb 4, 2016 · 0 comments

Comments

@mm-gmbd
Copy link

mm-gmbd commented Feb 4, 2016

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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant