mirror of https://github.com/vuejs/vue.git
feat(devtools): store functional render context on vnode in development (#8586)
This commit is contained in:
parent
2686818beb
commit
4ecc21c29e
|
|
@ -105,24 +105,27 @@ export function createFunctionalComponent (
|
||||||
const vnode = options.render.call(null, renderContext._c, renderContext)
|
const vnode = options.render.call(null, renderContext._c, renderContext)
|
||||||
|
|
||||||
if (vnode instanceof VNode) {
|
if (vnode instanceof VNode) {
|
||||||
return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
|
return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
|
||||||
} else if (Array.isArray(vnode)) {
|
} else if (Array.isArray(vnode)) {
|
||||||
const vnodes = normalizeChildren(vnode) || []
|
const vnodes = normalizeChildren(vnode) || []
|
||||||
const res = new Array(vnodes.length)
|
const res = new Array(vnodes.length)
|
||||||
for (let i = 0; i < vnodes.length; i++) {
|
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
|
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
|
// #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
|
// (e.g. it was from a cached normal slot) the fnContext causes named slots
|
||||||
// that should not be matched to match.
|
// that should not be matched to match.
|
||||||
const clone = cloneVNode(vnode)
|
const clone = cloneVNode(vnode)
|
||||||
clone.fnContext = contextVm
|
clone.fnContext = contextVm
|
||||||
clone.fnOptions = options
|
clone.fnOptions = options
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
;(clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext
|
||||||
|
}
|
||||||
if (data.slot) {
|
if (data.slot) {
|
||||||
(clone.data || (clone.data = {})).slot = data.slot
|
(clone.data || (clone.data = {})).slot = data.slot
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ export default class VNode {
|
||||||
ssrContext: Object | void;
|
ssrContext: Object | void;
|
||||||
fnContext: Component | void; // real context vm for functional nodes
|
fnContext: Component | void; // real context vm for functional nodes
|
||||||
fnOptions: ?ComponentOptions; // for SSR caching
|
fnOptions: ?ComponentOptions; // for SSR caching
|
||||||
|
devtoolsMeta: ?Object; // used to store functional render context for devtools
|
||||||
fnScopeId: ?string; // functional scope id support
|
fnScopeId: ?string; // functional scope id support
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue