]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat: scope id for child component
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Thu, 14 Nov 2024 12:52:19 +0000 (20:52 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Thu, 14 Nov 2024 12:52:23 +0000 (20:52 +0800)
packages/runtime-vapor/src/apiRender.ts

index 751a92c05674aeaf7cd7b2eff5b641500b7b9256..26a9b98cb742b79677530ff528cdf55adac5d87d 100644 (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, '')
+      }
+    }
+  }
+}