From af75b64b40b7a2df672f1b26ec4f22e6c5e9cd9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Thu, 14 Nov 2024 20:52:19 +0800 Subject: [PATCH] feat: scope id for child component --- packages/runtime-vapor/src/apiRender.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/runtime-vapor/src/apiRender.ts b/packages/runtime-vapor/src/apiRender.ts index 751a92c056..26a9b98cb7 100644 --- a/packages/runtime-vapor/src/apiRender.ts +++ b/packages/runtime-vapor/src/apiRender.ts @@ -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, '') + } + } + } +} -- 2.39.5