feat: scope id for child component

This commit is contained in:
三咲智子 Kevin Deng 2024-11-14 20:52:19 +08:00
parent 247617612a
commit af75b64b40
No known key found for this signature in database
1 changed files with 14 additions and 0 deletions

View File

@ -92,6 +92,7 @@ export function setupComponent(instance: ComponentInternalInstance): void {
}
instance.block = block
fallThroughAttrs(instance)
attachScopeId(instance)
return block
})
reset()
@ -166,3 +167,16 @@ export function unmountComponent(instance: ComponentInternalInstance): void {
)
flushPostFlushCbs()
}
export function attachScopeId(instance: ComponentInternalInstance): void {
const scopeId = instance.type.__scopeId
if (scopeId) {
let blk: Block | null = instance.block
while (blk && componentKey in blk) {
blk = blk.block
if (blk instanceof Element) {
blk.setAttribute(scopeId, '')
}
}
}
}