Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Commit dc3a559

Browse files
Allowing paths to be null for lookups. (#1145)
1 parent 4422c1b commit dc3a559

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export default class I18nPath {
289289
let i: number = 0
290290
while (i < length) {
291291
const value: any = last[paths[i]]
292-
if (value === undefined) {
292+
if (value === undefined || value === null) {
293293
return null
294294
}
295295
last = value

test/unit/path.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,10 @@ describe('path', () => {
8989
assert.strictEqual(path.getPathValue({}, 'a.b.c[]d'), null)
9090
})
9191
})
92+
93+
describe('obj: null child', () => {
94+
it('should return null if parent is null', () => {
95+
assert.strictEqual(path.getPathValue({ a: null }, 'a.b'), null)
96+
})
97+
})
9298
})

0 commit comments

Comments
 (0)