refactor(compiler): provide _ctx and _cache via arguments

This commit is contained in:
Evan You
2020-02-10 17:29:12 -05:00
parent ade07c64a1
commit 47e984d31f
21 changed files with 129 additions and 188 deletions

View File

@@ -199,7 +199,7 @@ export function generate(
push(`const render = _withId(`)
}
if (!ssr) {
push(`function render() {`)
push(`function render(_ctx, _cache) {`)
} else {
push(`function ssrRender(_ctx, _push, _parent) {`)
}
@@ -216,20 +216,9 @@ export function generate(
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
.join(', ')} } = _Vue`
)
if (ast.cached > 0) {
newline()
push(`const _cache = $cache`)
}
push(`\n`)
newline()
}
} else if (!__BROWSER__ && !ssr) {
push(`const _ctx = this`)
if (ast.cached > 0) {
newline()
push(`const _cache = _ctx.$cache`)
}
newline()
}
// generate asset resolution statements