refactor(utils): drop ie support (#3304)

* refactor(utils): drop ie support

* fix(utils): remove unused
This commit is contained in:
三咲智子 2021-09-10 15:00:39 +08:00 committed by GitHub
parent fc74a232a0
commit 200effa261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 56 deletions

View File

@ -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

View File

@ -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)

View File

@ -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<T>(watcherData: WatcherPropsData<T>) {
const { data, rowKey } = watcherData
let _currentRow = null
if (rowKey.value) {
_currentRow = arrayFind(
unref(data) || [],
_currentRow = (unref(data) || []).find(
(item) => getRowIdentity(item, rowKey.value) === key
)
}

View File

@ -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<T>() {
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) {

View File

@ -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<T>(props: Partial<TableBodyProps<T>>) {
getColspanRealWidth,
} = useStyles(props)
const firstDefaultColumnIndex = computed(() => {
return arrayFindIndex(
props.store.states.columns.value,
return props.store.states.columns.value.findIndex(
({ type }) => type === 'default'
)
})

View File

@ -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<Record<string, unknown>> => {
const instance = getCurrentInstance()
if (!instance) {
warn(
debugWarn(
'use-attrs',
'getCurrentInstance() returned null. useAttrs() must be called at the top of a setup function'
)

View File

@ -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<T>(obj: Hash<T>): [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 <T = any>(
arr: Array<T>,
pred: (args: T) => boolean
): number {
return arr.findIndex(pred)
}
export const arrayFind = function <T>(
arr: Array<T>,
pred: (args: T) => boolean
): T {
return arr.find(pred)
}
export function isEmpty(val: unknown) {
if (
(!val && val !== 0) ||