|
@ -1,6 +1,7 @@ |
|
|
/* @flow */ |
|
|
/* @flow */ |
|
|
|
|
|
|
|
|
import { encodeHTML } from 'entities' |
|
|
import { encodeHTML } from 'entities' |
|
|
|
|
|
import { compileToFunctions } from 'web/compiler/index' |
|
|
import { createComponentInstanceForVnode } from 'core/vdom/create-component' |
|
|
import { createComponentInstanceForVnode } from 'core/vdom/create-component' |
|
|
|
|
|
|
|
|
const normalizeAsync = (cache, method) => { |
|
|
const normalizeAsync = (cache, method) => { |
|
@ -14,6 +15,18 @@ const normalizeAsync = (cache, method) => { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const compilationCache = Object.create(null) |
|
|
|
|
|
const normalizeRender = vm => { |
|
|
|
|
|
const { render, template } = vm.$options |
|
|
|
|
|
if (!render && template) { |
|
|
|
|
|
const renderFns = ( |
|
|
|
|
|
compilationCache[template] || |
|
|
|
|
|
(compilationCache[template] = compileToFunctions(template)) |
|
|
|
|
|
) |
|
|
|
|
|
Object.assign(vm.$options, renderFns) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export function createRenderFunction ( |
|
|
export function createRenderFunction ( |
|
|
modules: Array<Function>, |
|
|
modules: Array<Function>, |
|
|
directives: Object, |
|
|
directives: Object, |
|
@ -77,9 +90,11 @@ export function createRenderFunction ( |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function renderComponent (node, write, next, isRoot) { |
|
|
function renderComponent (node, write, next, isRoot) { |
|
|
const child = createComponentInstanceForVnode(node)._render() |
|
|
const child = createComponentInstanceForVnode(node) |
|
|
child.parent = node |
|
|
normalizeRender(child) |
|
|
renderNode(child, write, next, isRoot) |
|
|
const childNode = child._render() |
|
|
|
|
|
childNode.parent = node |
|
|
|
|
|
renderNode(childNode, write, next, isRoot) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function renderComponentWithCache (node, write, next, isRoot, cache, key) { |
|
|
function renderComponentWithCache (node, write, next, isRoot, cache, key) { |
|
@ -179,6 +194,7 @@ export function createRenderFunction ( |
|
|
write: (text: string, next: Function) => void, |
|
|
write: (text: string, next: Function) => void, |
|
|
done: Function |
|
|
done: Function |
|
|
) { |
|
|
) { |
|
|
|
|
|
normalizeRender(component) |
|
|
renderNode(component._render(), write, done, true) |
|
|
renderNode(component._render(), write, done, true) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|