diff --git a/packages/runtime-vapor/src/apiRender.ts b/packages/runtime-vapor/src/apiRender.ts index 751a92c05..26a9b98cb 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, '') + } + } + } +}