[firestore][DocumentSnapshot] explicitly bind context on data/get methods to keep context during destructuring (includes tests)

This commit is contained in:
Salakar
2018-04-13 11:50:30 +01:00
parent ccb5f70dc1
commit c14e60017e
2 changed files with 51 additions and 7 deletions

View File

@@ -55,15 +55,13 @@ export default class DocumentSnapshot {
return this._ref;
}
data(): Object | void {
return this._data;
}
data = (): Object | void => this._data;
get(fieldPath: string | FieldPath): any {
get = (fieldPath: string | FieldPath): any => {
if (fieldPath instanceof FieldPath) {
return extractFieldPathData(this._data, fieldPath._segments);
}
return deepGet(this._data, fieldPath, '.');
}
};
}