read_varchain returns undefined instead of null
This commit is contained in:
parent
97e1658276
commit
08c3497788
11
coretool.js
11
coretool.js
@ -236,8 +236,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
read_varchain (path, root) {
|
||||
var parent = root || globalThis || global || window || {}
|
||||
var names = path.split('.')
|
||||
let parent = root || globalThis || global || window || {}
|
||||
let names = path.split('.')
|
||||
for (var i in names) {
|
||||
if (typeof parent === 'object' && names[i].match(/^\w+\(\)$/) && typeof parent[names[i].substring(0, names[i].length - 2)] === 'function') {
|
||||
// 支持 xxx.myfunc().yyy 的函数形式作为一个路径节点。
|
||||
@ -245,10 +245,13 @@ module.exports = {
|
||||
} else if (typeof parent === 'object' && names[i].match(/^\w+$/) && typeof parent[names[i]] != 'undefined' && parent[names[i]] != null) {
|
||||
parent = parent[names[i]]
|
||||
} else {
|
||||
return null
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
return parent === null || parent === undefined ? null : parent
|
||||
if (parent === null || parent === undefined || isNaN(parent) || typeof parent === 'number') {
|
||||
return undefined
|
||||
}
|
||||
return parent
|
||||
},
|
||||
|
||||
set_varchain (path, root, value) {
|
||||
|
Loading…
Reference in New Issue
Block a user