]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(runtime-core): replace VueElement import with ComponentCustomElementInterfac...
authoredison <daiwei521@126.com>
Thu, 22 Jan 2026 08:47:21 +0000 (16:47 +0800)
committerGitHub <noreply@github.com>
Thu, 22 Jan 2026 08:47:21 +0000 (16:47 +0800)
packages/runtime-core/src/component.ts
packages/runtime-core/src/renderer.ts
packages/runtime-dom/src/apiCustomElement.ts

index 4e1aa5e4d38dffef4351343401b7e6be9234f2fb..050429a66f67074d48e5d748928572816597bf06 100644 (file)
@@ -1257,6 +1257,10 @@ export function isClassComponent(value: unknown): value is ClassComponent {
 }
 
 export interface ComponentCustomElementInterface {
+  /**
+   * @internal
+   */
+  _isVueCE: boolean
   /**
    * @internal
    */
@@ -1286,4 +1290,8 @@ export interface ComponentCustomElementInterface {
    * @internal attached by the nested Teleport when shadowRoot is false.
    */
   _teleportTargets?: Set<RendererElement>
+  /**
+   * @internal check if shadow root is enabled
+   */
+  _hasShadowRoot(): boolean
 }
index d20bb2e8175a63f5ec7c1def606ba057f7986c00..be7cfccd3df3f70697cc6c8ee4ba46240fbfce20 100644 (file)
@@ -86,7 +86,7 @@ import { isAsyncWrapper } from './apiAsyncComponent'
 import { isCompatEnabled } from './compat/compatConfig'
 import { DeprecationTypes } from './compat/compatConfig'
 import { type TransitionHooks, leaveCbKey } from './components/BaseTransition'
-import type { VueElement } from '@vue/runtime-dom'
+import type { ComponentCustomElementInterface } from './component'
 
 export interface Renderer<HostElement = RendererElement> {
   render: RootRenderFunction<HostElement>
@@ -641,9 +641,10 @@ function baseCreateRenderer(
         optimized,
       )
     } else {
-      const customElement = !!(n1.el && (n1.el as VueElement)._isVueCE)
-        ? (n1.el as VueElement)
-        : null
+      const customElement =
+        n1.el && (n1.el as ComponentCustomElementInterface)._isVueCE
+          ? (n1.el as ComponentCustomElementInterface)
+          : null
       try {
         if (customElement) {
           customElement._beginPatch()
@@ -1385,11 +1386,7 @@ function baseCreateRenderer(
           }
         } else {
           // custom element style injection
-          if (
-            root.ce &&
-            // @ts-expect-error _def is private
-            (root.ce as VueElement)._def.shadowRoot !== false
-          ) {
+          if (root.ce && root.ce._hasShadowRoot()) {
             root.ce._injectChildStyle(type)
           }
 
index 3487922e2faf5f21279eee277530a45eb4374f20..9d18e7b22108974ea52989c501c0026db0d99c11 100644 (file)
@@ -725,6 +725,13 @@ export class VueElement
     }
   }
 
+  /**
+   * @internal
+   */
+  _hasShadowRoot(): boolean {
+    return this._def.shadowRoot !== false
+  }
+
   /**
    * @internal
    */