wip(ssr): handle <textarea> with dynamic key v-bind

This commit is contained in:
Evan You
2020-02-04 22:49:47 -05:00
parent 1958314976
commit 8da6df7235
9 changed files with 239 additions and 13 deletions

View File

@@ -17,7 +17,8 @@ import {
createCacheExpression,
createTemplateLiteral,
createBlockStatement,
createIfStatement
createIfStatement,
createAssignmentExpression
} from '../src'
import {
CREATE_VNODE,
@@ -40,6 +41,7 @@ function createRoot(options: Partial<RootNode> = {}): RootNode {
imports: [],
hoists: [],
cached: 0,
temps: 0,
codegenNode: createSimpleExpression(`null`, false),
loc: locStub,
...options
@@ -141,6 +143,15 @@ describe('compiler: codegen', () => {
expect(code).toMatchSnapshot()
})
test('temps', () => {
const root = createRoot({
temps: 3
})
const { code } = generate(root)
expect(code).toMatch(`let _temp0, _temp1, _temp2`)
expect(code).toMatchSnapshot()
})
test('prefixIdentifiers: true should inject _ctx statement', () => {
const { code } = generate(createRoot(), { prefixIdentifiers: true })
expect(code).toMatch(`const _ctx = this\n`)
@@ -540,4 +551,23 @@ describe('compiler: codegen', () => {
`)
})
})
test('AssignmentExpression', () => {
const { code } = generate(
createRoot({
codegenNode: createAssignmentExpression(
createSimpleExpression(`foo`, false),
createSimpleExpression(`bar`, false)
)
})
)
expect(code).toMatchInlineSnapshot(`
"
return function render() {
with (this) {
return (foo = bar)
}
}"
`)
})
})