Skip to content

Commit

Permalink
return null on nonexistent deeply nested property
Browse files Browse the repository at this point in the history
  • Loading branch information
blidd-google committed Jun 30, 2023
1 parent 258cdcd commit fdef746
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/v1/providers/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ describe("DataSnapshot", () => {
populate(applyChange({ a: 23 }, { b: 33 }));
expect(subject.child("a/b").val()).to.be.null;
expect(subject.child("b/c").val()).to.be.null;
expect(subject.child("a/b/c").val()).to.be.null;
});

it("should return a leaf value", () => {
Expand Down
3 changes: 3 additions & 0 deletions src/common/providers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export class DataSnapshot implements database.DataSnapshot {
let source = this._data;
if (parts.length) {
for (const part of parts) {
if (!source[part]) {
return null;
}
source = source[part];
}
}
Expand Down

0 comments on commit fdef746

Please sign in to comment.