mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
fix(hooks): rendering multiple popper container DOM in SSR/SSG (#18482)
This commit is contained in:
parent
0417037e0e
commit
f23ae6237a
@ -3,8 +3,6 @@ import { isClient } from '@element-plus/utils'
|
|||||||
import { useGetDerivedNamespace } from '../use-namespace'
|
import { useGetDerivedNamespace } from '../use-namespace'
|
||||||
import { useIdInjection } from '../use-id'
|
import { useIdInjection } from '../use-id'
|
||||||
|
|
||||||
let cachedContainer: HTMLElement
|
|
||||||
|
|
||||||
export const usePopperContainerId = () => {
|
export const usePopperContainerId = () => {
|
||||||
const namespace = useGetDerivedNamespace()
|
const namespace = useGetDerivedNamespace()
|
||||||
const idInjection = useIdInjection()
|
const idInjection = useIdInjection()
|
||||||
@ -37,10 +35,9 @@ export const usePopperContainer = () => {
|
|||||||
// for this we need to disable the caching since it's not really needed
|
// for this we need to disable the caching since it's not really needed
|
||||||
if (
|
if (
|
||||||
process.env.NODE_ENV === 'test' ||
|
process.env.NODE_ENV === 'test' ||
|
||||||
!cachedContainer ||
|
|
||||||
!document.body.querySelector(selector.value)
|
!document.body.querySelector(selector.value)
|
||||||
) {
|
) {
|
||||||
cachedContainer = createContainer(id.value)
|
createContainer(id.value)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user