mirror of https://github.com/vuejs/core.git
fix(runtime-core): update devtool __vnode on patch, avoid memory leak during dev
close #11192
This commit is contained in:
parent
3169c91493
commit
a959781dd6
|
@ -17,6 +17,7 @@ import { warn } from './warning'
|
||||||
import {
|
import {
|
||||||
PatchFlags,
|
PatchFlags,
|
||||||
ShapeFlags,
|
ShapeFlags,
|
||||||
|
def,
|
||||||
includeBooleanAttr,
|
includeBooleanAttr,
|
||||||
isBooleanAttr,
|
isBooleanAttr,
|
||||||
isKnownHtmlAttr,
|
isKnownHtmlAttr,
|
||||||
|
@ -141,18 +142,8 @@ export function createHydrationFunctions(
|
||||||
vnode.el = node
|
vnode.el = node
|
||||||
|
|
||||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||||
if (!('__vnode' in node)) {
|
def(node, '__vnode', vnode, true)
|
||||||
Object.defineProperty(node, '__vnode', {
|
def(node, '__vueParentComponent', parentComponent, true)
|
||||||
value: vnode,
|
|
||||||
enumerable: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (!('__vueParentComponent' in node)) {
|
|
||||||
Object.defineProperty(node, '__vueParentComponent', {
|
|
||||||
value: parentComponent,
|
|
||||||
enumerable: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patchFlag === PatchFlags.BAIL) {
|
if (patchFlag === PatchFlags.BAIL) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import {
|
||||||
NOOP,
|
NOOP,
|
||||||
PatchFlags,
|
PatchFlags,
|
||||||
ShapeFlags,
|
ShapeFlags,
|
||||||
|
def,
|
||||||
getGlobalThis,
|
getGlobalThis,
|
||||||
invokeArrayFns,
|
invokeArrayFns,
|
||||||
isArray,
|
isArray,
|
||||||
|
@ -696,15 +697,10 @@ function baseCreateRenderer(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||||
Object.defineProperty(el, '__vnode', {
|
def(el, '__vnode', vnode, true)
|
||||||
value: vnode,
|
def(el, '__vueParentComponent', parentComponent, true)
|
||||||
enumerable: false,
|
|
||||||
})
|
|
||||||
Object.defineProperty(el, '__vueParentComponent', {
|
|
||||||
value: parentComponent,
|
|
||||||
enumerable: false,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirs) {
|
if (dirs) {
|
||||||
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount')
|
||||||
}
|
}
|
||||||
|
@ -805,6 +801,9 @@ function baseCreateRenderer(
|
||||||
optimized: boolean,
|
optimized: boolean,
|
||||||
) => {
|
) => {
|
||||||
const el = (n2.el = n1.el!)
|
const el = (n2.el = n1.el!)
|
||||||
|
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||||
|
el.__vnode = n2
|
||||||
|
}
|
||||||
let { patchFlag, dynamicChildren, dirs } = n2
|
let { patchFlag, dynamicChildren, dirs } = n2
|
||||||
// #1426 take the old vnode's patch flag into account since user may clone a
|
// #1426 take the old vnode's patch flag into account since user may clone a
|
||||||
// compiler-generated vnode, which de-opts to FULL_PROPS
|
// compiler-generated vnode, which de-opts to FULL_PROPS
|
||||||
|
|
Loading…
Reference in New Issue