fix(components): [tree] the value of append can be zero (#16130)

This commit is contained in:
btea
2024-03-18 07:34:27 +08:00
committed by GitHub
parent 54f11892a3
commit fec8a5de05

View File

@@ -1,5 +1,5 @@
// @ts-nocheck
import { hasOwn, isObject } from '@element-plus/utils'
import { hasOwn, isObject, isPropAbsent } from '@element-plus/utils'
import Node from './node'
import { getNodeKey } from './util'
@@ -144,7 +144,9 @@ export default class TreeStore {
}
append(data: TreeNodeData, parentData: TreeNodeData | TreeKey | Node): void {
const parentNode = parentData ? this.getNode(parentData) : this.root
const parentNode = !isPropAbsent(parentData)
? this.getNode(parentData)
: this.root
if (parentNode) {
parentNode.insertChild({ data })