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

@@ -183,12 +183,6 @@ describe('compiler: codegen', () => {
expect(code).toMatchSnapshot()
})
test('prefixIdentifiers: true should inject _ctx statement', () => {
const { code } = generate(createRoot(), { prefixIdentifiers: true })
expect(code).toMatch(`const _ctx = this\n`)
expect(code).toMatchSnapshot()
})
test('static text', () => {
const { code } = generate(
createRoot({
@@ -422,7 +416,6 @@ describe('compiler: codegen', () => {
prefixIdentifiers: true
}
)
expect(code).toMatch(`const _cache = _ctx.$cache`)
expect(code).toMatch(`_cache[1] || (_cache[1] = foo)`)
expect(code).toMatchSnapshot()
})
@@ -442,7 +435,6 @@ describe('compiler: codegen', () => {
prefixIdentifiers: true
}
)
expect(code).toMatch(`const _cache = _ctx.$cache`)
expect(code).toMatch(
`
_cache[1] || (
@@ -596,7 +588,7 @@ describe('compiler: codegen', () => {
)
expect(code).toMatchInlineSnapshot(`
"
return function render() {
return function render(_ctx, _cache) {
with (this) {
return foo = bar
}