فهرست منبع

fix(devtools): allow devtools to identify parent components of hydrated elements.

Thorsten Luenborg 3 سال پیش
والد
کامیت
934f26f7d8
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      packages/runtime-core/src/hydration.ts

+ 10 - 0
packages/runtime-core/src/hydration.ts

@@ -354,6 +354,16 @@ export function createHydrationFunctions(
           )
         }
       }
+      if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
+        Object.defineProperty(el, '__vnode', {
+          value: vnode,
+          enumerable: false
+        })
+        Object.defineProperty(el, '__vueParentComponent', {
+          value: parentComponent,
+          enumerable: false
+        })
+      }
       // vnode / directive hooks
       let vnodeHooks: VNodeHook | null | undefined
       if ((vnodeHooks = props && props.onVnodeBeforeMount)) {