mirror of https://github.com/vuejs/core.git
fix(custom-element): optimize slot retrieval to avoid duplicates
This commit is contained in:
parent
c16f8a94c7
commit
f41d16e6c7
|
@ -685,11 +685,23 @@ export class VueElement
|
||||||
if (this._teleportTargets) {
|
if (this._teleportTargets) {
|
||||||
roots.push(...this._teleportTargets)
|
roots.push(...this._teleportTargets)
|
||||||
}
|
}
|
||||||
return roots.reduce<HTMLSlotElement[]>((res, i) => {
|
|
||||||
res.push(...Array.from(i.querySelectorAll('slot')))
|
const seen = new Set<HTMLSlotElement>()
|
||||||
return res
|
const slots: HTMLSlotElement[] = []
|
||||||
}, [])
|
for (const root of roots) {
|
||||||
|
const found = root.querySelectorAll<HTMLSlotElement>('slot')
|
||||||
|
for (let i = 0; i < found.length; i++) {
|
||||||
|
const slot = found[i]
|
||||||
|
if (!seen.has(slot)) {
|
||||||
|
seen.add(slot)
|
||||||
|
slots.push(slot)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return slots
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue