From fd32fb04f9035770860ebe1d6a090e76b77288cb Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Wed, 1 Aug 2018 14:38:24 +0200 Subject: [PATCH 1/3] feat: Store functional render context on vnode in development --- src/core/vdom/create-functional-component.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/vdom/create-functional-component.js b/src/core/vdom/create-functional-component.js index efed801db7d..500b6393d41 100644 --- a/src/core/vdom/create-functional-component.js +++ b/src/core/vdom/create-functional-component.js @@ -105,24 +105,27 @@ export function createFunctionalComponent ( const vnode = options.render.call(null, renderContext._c, renderContext) if (vnode instanceof VNode) { - return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options) + return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext) } else if (Array.isArray(vnode)) { const vnodes = normalizeChildren(vnode) || [] const res = new Array(vnodes.length) for (let i = 0; i < vnodes.length; i++) { - res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options) + res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext) } return res } } -function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) { +function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) { // #7817 clone node before setting fnContext, otherwise if the node is reused // (e.g. it was from a cached normal slot) the fnContext causes named slots // that should not be matched to match. const clone = cloneVNode(vnode) clone.fnContext = contextVm clone.fnOptions = options + if (process.env.NODE_ENV !== 'production') { + clone.devtoolsMeta = renderContext + } if (data.slot) { (clone.data || (clone.data = {})).slot = data.slot } From dcf2017dfda9659b5e656f81b2de57c77f2f8908 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Wed, 1 Aug 2018 14:58:12 +0200 Subject: [PATCH 2/3] fix: Add flow type declaration --- src/core/vdom/vnode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/vdom/vnode.js b/src/core/vdom/vnode.js index c3e00078fea..0e3e2e9e635 100644 --- a/src/core/vdom/vnode.js +++ b/src/core/vdom/vnode.js @@ -26,6 +26,7 @@ export default class VNode { ssrContext: Object | void; fnContext: Component | void; // real context vm for functional nodes fnOptions: ?ComponentOptions; // for SSR caching + devtoolsMeta: ?Object; // used to store functional render context for devtools fnScopeId: ?string; // functional scope id support constructor ( From d15b7fc8839484f8fae8190c0e43e8829a6e7a96 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Fri, 3 Aug 2018 00:46:49 +0200 Subject: [PATCH 3/3] fix: Use `devtoolsMeta.renderContext` instead --- src/core/vdom/create-functional-component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/vdom/create-functional-component.js b/src/core/vdom/create-functional-component.js index 500b6393d41..4233ade22e8 100644 --- a/src/core/vdom/create-functional-component.js +++ b/src/core/vdom/create-functional-component.js @@ -124,7 +124,7 @@ function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderCo clone.fnContext = contextVm clone.fnOptions = options if (process.env.NODE_ENV !== 'production') { - clone.devtoolsMeta = renderContext + ;(clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext } if (data.slot) { (clone.data || (clone.data = {})).slot = data.slot