Selaa lähdekoodia

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

Thorsten Luenborg 3 vuotta sitten
vanhempi
commit
934f26f7d8
1 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  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)) {