added manual rendering

This commit is contained in:
Blake Newman 2016-05-07 19:20:43 +01:00
parent a233e4dbfa
commit d89c674cb5
2 changed files with 34 additions and 15 deletions

View File

@ -39,6 +39,18 @@ export function lifecycleMixin (Vue) {
}
}
}
this.renderStaticTrees()
this._watcher = new Watcher(this, this._render, this._update)
this._update(this._watcher.value)
this._mounted = true
// root instance, call ready on self
if (this.$root === this) {
callHook(this, 'ready')
}
return this
}
Vue.prototype._renderStaticTrees = function () {
// render static sub-trees for once on mount
const staticRenderFns = this.$options.staticRenderFns
if (staticRenderFns) {
@ -47,13 +59,6 @@ export function lifecycleMixin (Vue) {
this._staticTrees[i] = staticRenderFns[i].call(this._renderProxy)
}
}
this._watcher = new Watcher(this, this._render, this._update)
this._update(this._watcher.value)
this._mounted = true
// root instance, call ready on self
if (this.$root === this) {
callHook(this, 'ready')
}
return this
}

View File

@ -1,15 +1,28 @@
import { renderStartingTag } from './render-starting-tag'
export function render (modules, directives, isUnaryTag) {
function renderComponent (component, write, next, isRoot) {
component.$mount()
renderNode(component._vnode, write, next, isRoot)
}
function renderNode (node, write, next, isRoot) {
if (node.componentOptions) {
node.data.hook.init(node)
renderComponent(node.child, write, next, isRoot)
const { Ctor, propsData, listeners, parent, children } = node.componentOptions
const options = {
parent,
propsData,
_parentVnode: node,
_parentListeners: listeners,
_renderChildren: children
}
// check inline-template render functions
const inlineTemplate = node.data.inlineTemplate
if (inlineTemplate) {
options.render = inlineTemplate.render
options.staticRenderFns = inlineTemplate.staticRenderFns
}
const child = new Ctor(options)
child._mount = () => {
child._renderStaticTrees()
renderNode(child._render(), write, next)
}
child.$mount(node.elm)
} else {
if (node.tag) {
renderElement(node, write, next, isRoot)
@ -53,6 +66,7 @@ export function render (modules, directives, isUnaryTag) {
}
return function render (component, write, done) {
renderComponent(component, write, done, true)
component._renderStaticTrees()
renderNode(component._render(), write, done, true)
}
}