Sfoglia il codice sorgente

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

Thorsten Luenborg 3 anni fa
parent
commit
934f26f7d8
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  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)) {