diff --git a/packages/components/infinite-scroll/src/index.ts b/packages/components/infinite-scroll/src/index.ts index 4f32230b23..4c1ccf782f 100644 --- a/packages/components/infinite-scroll/src/index.ts +++ b/packages/components/infinite-scroll/src/index.ts @@ -6,7 +6,6 @@ import { getOffsetTopDistance, } from '@element-plus/utils/dom' import { throwError } from '@element-plus/utils/error' -import { entries } from '@element-plus/utils/util' import type { ObjectDirective, ComponentPublicInstance } from 'vue' @@ -54,7 +53,7 @@ const getScrollOptions = ( el: HTMLElement, instance: ComponentPublicInstance ): ScrollOptions => { - return entries(attributes).reduce((acm, [name, option]) => { + return Object.entries(attributes).reduce((acm, [name, option]) => { const { type, default: defaultValue } = option const attrVal = el.getAttribute(`infinite-scroll-${name}`) let value = instance[attrVal] ?? attrVal ?? defaultValue diff --git a/packages/components/select/src/useSelect.ts b/packages/components/select/src/useSelect.ts index 3c5dcd41a7..a492ce0801 100644 --- a/packages/components/select/src/useSelect.ts +++ b/packages/components/select/src/useSelect.ts @@ -7,12 +7,7 @@ import isServer from '@element-plus/utils/isServer' import scrollIntoView from '@element-plus/utils/scroll-into-view' import lodashDebounce from 'lodash/debounce' import { isKorean } from '@element-plus/utils/isDef' -import { - getValueByPath, - isIE, - isEdge, - useGlobalConfig, -} from '@element-plus/utils/util' +import { getValueByPath, useGlobalConfig } from '@element-plus/utils/util' import { elFormKey, elFormItemKey } from '@element-plus/tokens' import isEqual from 'lodash/isEqual' import { isObject, toRawType } from '@vue/shared' @@ -72,10 +67,7 @@ export const useSelect = (props, states: States, ctx) => { const elFormItem = inject(elFormItemKey, {} as ElFormItemContext) const readonly = computed( - () => - !props.filterable || - props.multiple || - (!isIE() && !isEdge() && !states.visible) + () => !props.filterable || props.multiple || !states.visible ) const selectDisabled = computed(() => props.disabled || elForm.disabled) diff --git a/packages/components/table/src/store/current.ts b/packages/components/table/src/store/current.ts index 19b332427e..9b8ed1e353 100644 --- a/packages/components/table/src/store/current.ts +++ b/packages/components/table/src/store/current.ts @@ -1,5 +1,4 @@ import { ref, getCurrentInstance, unref } from 'vue' -import { arrayFind } from '@element-plus/utils/util' import { getRowIdentity } from '../util' import type { Ref } from 'vue' @@ -25,8 +24,7 @@ function useCurrent(watcherData: WatcherPropsData) { const { data, rowKey } = watcherData let _currentRow = null if (rowKey.value) { - _currentRow = arrayFind( - unref(data) || [], + _currentRow = (unref(data) || []).find( (item) => getRowIdentity(item, rowKey.value) === key ) } diff --git a/packages/components/table/src/store/index.ts b/packages/components/table/src/store/index.ts index 1e55fbedc1..71a7de0eef 100644 --- a/packages/components/table/src/store/index.ts +++ b/packages/components/table/src/store/index.ts @@ -1,5 +1,4 @@ import { nextTick, getCurrentInstance, unref } from 'vue' -import { arrayFind } from '@element-plus/utils/util' import useWatcher from './watcher' import type { Ref } from 'vue' @@ -126,8 +125,7 @@ function useStore() { sort(states: StoreStates, options: Sort) { const { prop, order, init } = options if (prop) { - const column = arrayFind( - unref(states.columns), + const column = unref(states.columns).find( (column) => column.property === prop ) if (column) { diff --git a/packages/components/table/src/table-body/render-helper.ts b/packages/components/table/src/table-body/render-helper.ts index cdfa40db0f..ab6d6ce30b 100644 --- a/packages/components/table/src/table-body/render-helper.ts +++ b/packages/components/table/src/table-body/render-helper.ts @@ -1,5 +1,4 @@ import { h, getCurrentInstance, computed } from 'vue' -import { arrayFindIndex } from '@element-plus/utils/util' import useEvents from './events-helper' import useStyles from './styles-helper' import { getRowIdentity } from '../util' @@ -31,8 +30,7 @@ function useRender(props: Partial>) { getColspanRealWidth, } = useStyles(props) const firstDefaultColumnIndex = computed(() => { - return arrayFindIndex( - props.store.states.columns.value, + return props.store.states.columns.value.findIndex( ({ type }) => type === 'default' ) }) diff --git a/packages/hooks/use-attrs/index.ts b/packages/hooks/use-attrs/index.ts index 2b86602517..fed3e4fa25 100644 --- a/packages/hooks/use-attrs/index.ts +++ b/packages/hooks/use-attrs/index.ts @@ -1,5 +1,5 @@ import { getCurrentInstance, computed } from 'vue' -import { warn } from '@element-plus/utils/error' +import { debugWarn } from '@element-plus/utils/error' import type { ComputedRef } from 'vue' @@ -17,7 +17,7 @@ export default (params: Params = {}): ComputedRef> => { const instance = getCurrentInstance() if (!instance) { - warn( + debugWarn( 'use-attrs', 'getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function' ) diff --git a/packages/utils/util.ts b/packages/utils/util.ts index e44f35e23a..8db56c9afe 100644 --- a/packages/utils/util.ts +++ b/packages/utils/util.ts @@ -17,14 +17,7 @@ import isServer from './isServer' import { debugWarn } from './error' import type { ComponentPublicInstance, CSSProperties, Ref } from 'vue' -import type { AnyFunction, TimeoutHandle, Hash, Nullable } from './types' - -// type polyfill for compat isIE method -declare global { - interface Document { - documentMode?: any - } -} +import type { AnyFunction, TimeoutHandle, Nullable } from './types' export const SCOPE = 'Util' @@ -103,13 +96,9 @@ export const coerceTruthyValueToArray = (arr) => { return Array.isArray(arr) ? arr : [arr] } -export const isIE = function (): boolean { - return !isServer && !isNaN(Number(document.documentMode)) -} - -export const isEdge = function (): boolean { - return !isServer && navigator.userAgent.indexOf('Edge') > -1 -} +// drop IE and (Edge < 79) support +// export const isIE +// export const isEdge export const isFirefox = function (): boolean { return !isServer && !!window.navigator.userAgent.match(/firefox/i) @@ -177,10 +166,6 @@ export function getRandomInt(max: number) { return Math.floor(Math.random() * Math.floor(max)) } -export function entries(obj: Hash): [string, T][] { - return Object.keys(obj).map((key: string) => [key, obj[key]]) -} - export function isUndefined(val: any): val is undefined { return val === undefined } @@ -193,20 +178,6 @@ export function useGlobalConfig() { return {} } -export const arrayFindIndex = function ( - arr: Array, - pred: (args: T) => boolean -): number { - return arr.findIndex(pred) -} - -export const arrayFind = function ( - arr: Array, - pred: (args: T) => boolean -): T { - return arr.find(pred) -} - export function isEmpty(val: unknown) { if ( (!val && val !== 0) ||