Skip to content

Commit 5b03554

Browse files
committed
fix: support null values
1 parent 62b6ef8 commit 5b03554

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function extractRefs (doc, oldDoc, path = '', result = [{}, {}]) {
2929
extractRefs(ref, oldDoc[key], path + key + '.', [tot[0][key], tot[1]])
3030
} else if (
3131
ref instanceof Date ||
32+
ref == null ||
3233
(ref.longitude && ref.latitude) // GeoPoint
3334
) {
3435
tot[0][key] = ref

test/utils.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ test('extract object nested refs from document', () => {
7979
})
8080
})
8181

82+
test('works with null', () => {
83+
const [noRefsDoc, refs] = extractRefs({
84+
a: null,
85+
nested: {
86+
a: null
87+
}
88+
})
89+
expect(noRefsDoc).toEqual({
90+
a: null,
91+
nested: {
92+
a: null
93+
}
94+
})
95+
expect(refs).toEqual({})
96+
})
97+
8298
test('extract deep object nested refs from document', () => {
8399
const [noRefsDoc, refs] = extractRefs({
84100
obj: {

0 commit comments

Comments
 (0)