diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29bb..e97214632 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +- Fixes access on deeply nested, nonexistent property. (#1432) diff --git a/spec/v1/providers/database.spec.ts b/spec/v1/providers/database.spec.ts index 874b1de29..18d973b1d 100644 --- a/spec/v1/providers/database.spec.ts +++ b/spec/v1/providers/database.spec.ts @@ -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", () => { diff --git a/src/common/providers/database.ts b/src/common/providers/database.ts index 33250f4c0..1200cc73a 100644 --- a/src/common/providers/database.ts +++ b/src/common/providers/database.ts @@ -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] === undefined) { + return null; + } source = source[part]; } }