Skip to content

Commit 87c3d2e

Browse files
znckyyx990803
authored andcommitted
feat(compiler-core): create transform for v-model (vuejs#146)
1 parent 99bdc5a commit 87c3d2e

File tree

6 files changed

+557
-4
lines changed

6 files changed

+557
-4
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`compiler: transform v-model compound expression (with prefixIdentifiers) 1`] = `
4+
"import { createVNode, createBlock, openBlock } from \\"vue\\"
5+
6+
export default function render() {
7+
const _ctx = this
8+
return (openBlock(), createBlock(\\"input\\", {
9+
modelValue: _ctx.model[_ctx.index],
10+
\\"onUpdate:modelValue\\": $event => (_ctx.model[_ctx.index] = $event)
11+
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
12+
}"
13+
`;
14+
15+
exports[`compiler: transform v-model compound expression 1`] = `
16+
"const _Vue = Vue
17+
18+
return function render() {
19+
with (this) {
20+
const { createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = _Vue
21+
22+
return (_openBlock(), _createBlock(\\"input\\", {
23+
modelValue: model[index],
24+
\\"onUpdate:modelValue\\": $event => (model[index] = $event)
25+
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
26+
}
27+
}"
28+
`;
29+
30+
exports[`compiler: transform v-model simple exprssion (with prefixIdentifiers) 1`] = `
31+
"import { createVNode, createBlock, openBlock } from \\"vue\\"
32+
33+
export default function render() {
34+
const _ctx = this
35+
return (openBlock(), createBlock(\\"input\\", {
36+
modelValue: _ctx.model,
37+
\\"onUpdate:modelValue\\": $event => (_ctx.model = $event)
38+
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
39+
}"
40+
`;
41+
42+
exports[`compiler: transform v-model simple exprssion 1`] = `
43+
"const _Vue = Vue
44+
45+
return function render() {
46+
with (this) {
47+
const { createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = _Vue
48+
49+
return (_openBlock(), _createBlock(\\"input\\", {
50+
modelValue: model,
51+
\\"onUpdate:modelValue\\": $event => (model = $event)
52+
}, null, 8 /* PROPS */, [\\"modelValue\\", \\"onUpdate:modelValue\\"]))
53+
}
54+
}"
55+
`;
56+
57+
exports[`compiler: transform v-model with argument 1`] = `
58+
"const _Vue = Vue
59+
60+
return function render() {
61+
with (this) {
62+
const { createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = _Vue
63+
64+
return (_openBlock(), _createBlock(\\"input\\", {
65+
value: model,
66+
\\"onUpdate:value\\": $event => (model = $event)
67+
}, null, 8 /* PROPS */, [\\"value\\", \\"onUpdate:value\\"]))
68+
}
69+
}"
70+
`;
71+
72+
exports[`compiler: transform v-model with dynamic argument (with prefixIdentifiers) 1`] = `
73+
"import { createVNode, createBlock, openBlock } from \\"vue\\"
74+
75+
export default function render() {
76+
const _ctx = this
77+
return (openBlock(), createBlock(\\"input\\", {
78+
[_ctx.value]: _ctx.model,
79+
[\\"onUpdate:\\"+_ctx.value]: $event => (_ctx.model = $event)
80+
}, null, 16 /* FULL_PROPS */))
81+
}"
82+
`;
83+
84+
exports[`compiler: transform v-model with dynamic argument 1`] = `
85+
"const _Vue = Vue
86+
87+
return function render() {
88+
with (this) {
89+
const { createVNode: _createVNode, createBlock: _createBlock, openBlock: _openBlock } = _Vue
90+
91+
return (_openBlock(), _createBlock(\\"input\\", {
92+
[value]: model,
93+
[\\"onUpdate:\\"+value]: $event => (model = $event)
94+
}, null, 16 /* FULL_PROPS */))
95+
}
96+
}"
97+
`;

0 commit comments

Comments
 (0)