|
|
@@ -7,19 +7,9 @@ import { cloneVNode, cloneVNodes } from 'core/vdom/vnode'
|
|
|
*/
|
|
|
export function renderStatic (
|
|
|
index: number,
|
|
|
- isInFor: boolean,
|
|
|
- isOnce: boolean
|
|
|
+ isInFor: boolean
|
|
|
): VNode | Array<VNode> {
|
|
|
- // render fns generated by compiler < 2.5.4 does not provide v-once
|
|
|
- // information to runtime so be conservative
|
|
|
- const isOldVersion = arguments.length < 3
|
|
|
- // if a static tree is generated by v-once, it is cached on the instance;
|
|
|
- // otherwise it is purely static and can be cached on the shared options
|
|
|
- // across all instances.
|
|
|
- const renderFns = this.$options.staticRenderFns
|
|
|
- const cached = isOldVersion || isOnce
|
|
|
- ? (this._staticTrees || (this._staticTrees = []))
|
|
|
- : (renderFns.cached || (renderFns.cached = []))
|
|
|
+ const cached = this._staticTrees || (this._staticTrees = [])
|
|
|
let tree = cached[index]
|
|
|
// if has already-rendered static tree and not inside v-for,
|
|
|
// we can reuse the same tree by doing a shallow clone.
|
|
|
@@ -29,7 +19,11 @@ export function renderStatic (
|
|
|
: cloneVNode(tree)
|
|
|
}
|
|
|
// otherwise, render a fresh tree.
|
|
|
- tree = cached[index] = renderFns[index].call(this._renderProxy, null, this)
|
|
|
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
|
|
|
+ this._renderProxy,
|
|
|
+ null,
|
|
|
+ this // for render fns generated for functional component templates
|
|
|
+ )
|
|
|
markStatic(tree, `__static__${index}`, false)
|
|
|
return tree
|
|
|
}
|