mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
refactor(components): use built-in methods to check for undefined and null (#20537)
style(components): check the undefined type for unification
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
isArray,
|
||||
isObject,
|
||||
isString,
|
||||
isUndefined,
|
||||
mutable,
|
||||
} from '@element-plus/utils'
|
||||
import { useNamespace } from '@element-plus/hooks'
|
||||
@@ -190,7 +191,7 @@ export const menuEmits = {
|
||||
isString(index) &&
|
||||
checkIndexPath(indexPath) &&
|
||||
isObject(item) &&
|
||||
(routerResult === undefined || routerResult instanceof Promise),
|
||||
(isUndefined(routerResult) || routerResult instanceof Promise),
|
||||
}
|
||||
export type MenuEmits = typeof menuEmits
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
buildProps,
|
||||
iconPropType,
|
||||
isString,
|
||||
isUndefined,
|
||||
throwError,
|
||||
} from '@element-plus/utils'
|
||||
import { useNamespace } from '@element-plus/hooks'
|
||||
@@ -148,7 +149,7 @@ export default defineComponent({
|
||||
const isFirstLevel = computed(() => subMenu.level === 0)
|
||||
const appendToBody = computed(() => {
|
||||
const value = props.teleported
|
||||
return value === undefined ? isFirstLevel.value : value
|
||||
return isUndefined(value) ? isFirstLevel.value : value
|
||||
})
|
||||
const menuTransitionName = computed(() =>
|
||||
rootMenu.props.collapse
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
isFunction,
|
||||
isNumber,
|
||||
isObject,
|
||||
isUndefined,
|
||||
} from '@element-plus/utils'
|
||||
import {
|
||||
useComposition,
|
||||
@@ -686,7 +687,7 @@ const useSelect = (props: ISelectV2Props, emit: SelectEmitFn) => {
|
||||
if (!expanded.value) {
|
||||
return toggleMenu()
|
||||
}
|
||||
if (hoveringIndex === undefined) {
|
||||
if (isUndefined(hoveringIndex)) {
|
||||
hoveringIndex = states.hoveringIndex
|
||||
}
|
||||
let newIndex = -1
|
||||
|
||||
@@ -75,7 +75,7 @@ const getPropertyFromData = function (node: Node, prop: string): any {
|
||||
return data[config]
|
||||
} else if (isUndefined(config)) {
|
||||
const dataProp = data[prop]
|
||||
return dataProp === undefined ? '' : dataProp
|
||||
return isUndefined(dataProp) ? '' : dataProp
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ class Node {
|
||||
children = props.children || 'children'
|
||||
}
|
||||
|
||||
if (data[children] === undefined) {
|
||||
if (isUndefined(data[children])) {
|
||||
data[children] = null
|
||||
}
|
||||
|
||||
|
||||
@@ -412,7 +412,7 @@ export default class TreeStore {
|
||||
|
||||
setCurrentNodeKey(key?: TreeKey, shouldAutoExpandParent = true): void {
|
||||
this.currentNodeKey = key
|
||||
if (key === null || key === undefined) {
|
||||
if (isPropAbsent(key)) {
|
||||
this.currentNode && (this.currentNode.isCurrent = false)
|
||||
this.currentNode = null
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user