mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* feat(components): anchor component * fix(components): [anchor] marker opacity style * test(components): [anchor] update snapshots * fix(components): [anchor] style change and add version tag * docs(components): [anchor] affix mode demo add affix offset * fix(components): [anchor] change api * fix: slot name change * fix: scrollTo method change * fix: delete getCurrentAnchor api * style: text overflow * docs: change toc to anchor * refactor: useEventListener * fix: update * fix: update
17 lines
474 B
TypeScript
17 lines
474 B
TypeScript
import { isString } from '../types'
|
|
import { isClient } from '../browser'
|
|
|
|
type GetElement = <T extends string | HTMLElement | Window | null | undefined>(
|
|
target: T
|
|
) => T extends string ? HTMLElement | null : T
|
|
|
|
export const getElement = ((
|
|
target: string | HTMLElement | Window | null | undefined
|
|
) => {
|
|
if (!isClient || target === '') return null
|
|
if (isString(target)) {
|
|
return document.querySelector<HTMLElement>(target)
|
|
}
|
|
return target
|
|
}) as GetElement
|