Skip to content

Commit

Permalink
chore(core): improve allowAssignDefaultValue (#3523)
Browse files Browse the repository at this point in the history
  • Loading branch information
hchlq authored Nov 7, 2022
1 parent d6a894f commit 666b867
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions packages/core/src/shared/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,28 +1027,21 @@ export const getValidFieldDefaultValue = (value: any, initialValue: any) => {
}

export const allowAssignDefaultValue = (target: any, source: any) => {
const isEmptyTarget = target !== null && isEmpty(target)
const isEmptySource = source !== null && isEmpty(source)
const isValidTarget = !isUndef(target)
const isValidSource = !isUndef(source)
if (!isValidTarget) {
if (isValidSource) {
return true
}
return false
return isValidSource
}

if (typeof target === typeof source) {
if (target === '') return false
if (target === 0) return false
}

const isEmptyTarget = target !== null && isEmpty(target)
const isEmptySource = source !== null && isEmpty(source)
if (isEmptyTarget) {
if (isEmptySource) {
return false
} else {
return true
}
return !isEmptySource
}
return false
}
Expand Down

0 comments on commit 666b867

Please sign in to comment.