@@ -34,51 +34,59 @@ const tests = [
34
34
{
35
35
name : 'Ignores non vModel arguments' ,
36
36
from : `const a = { setup: () => { return () => <A x="y" a:b={c} /> } }` ,
37
- to : `const a = {
37
+ to : `
38
+ const a = {
38
39
setup: () => {
39
40
return () => <A x="y" a:b={c} />;
40
41
}
41
- };` ,
42
+ };` . trim ( ) ,
42
43
} ,
43
44
{
44
45
name : 'Generic component vModel' ,
45
46
from : `const a = { setup: () => { return () => <MyComponent vModel={a.b} /> } }` ,
46
- to : `import { getCurrentInstance } from "@vue/composition-api";
47
+ to : `
48
+ import { getCurrentInstance } from "@vue/composition-api";
47
49
const a = {
48
50
setup: () => {
51
+ const __currentInstance = getCurrentInstance();
52
+
49
53
return () => <MyComponent model={{
50
54
value: a.b,
51
55
callback: $$v => {
52
- getCurrentInstance() .$set(a, "b", $$v);
56
+ __currentInstance .$set(a, "b", $$v);
53
57
}
54
58
}} />;
55
59
}
56
- };` ,
60
+ };` . trim ( ) ,
57
61
} ,
58
62
{
59
63
name : 'Component vModel_number' ,
60
64
from : `const a = { setup: () => { return () => <MyComponent vModel_number={a.b} /> } }` ,
61
- to : `import { getCurrentInstance } from "@vue/composition-api";
65
+ to : `
66
+ import { getCurrentInstance } from "@vue/composition-api";
62
67
const a = {
63
68
setup: () => {
69
+ const __currentInstance = getCurrentInstance();
70
+
64
71
return () => <MyComponent model={{
65
72
value: a.b,
66
73
callback: $$v => {
67
- getCurrentInstance() .$set(a, "b", getCurrentInstance() ._n($$v));
74
+ __currentInstance .$set(a, "b", __currentInstance ._n($$v));
68
75
}
69
76
}} />;
70
77
}
71
- };` ,
78
+ };` . trim ( ) ,
72
79
} ,
73
80
{
74
81
name : 'Ignore outside of setup()' ,
75
82
from : `const A = <MyComponent vModel={a[b]} />` ,
76
- to : `const A = <MyComponent model={{
83
+ to : `
84
+ const A = <MyComponent model={{
77
85
value: a[b],
78
86
callback: $$v => {
79
87
this.$set(a, b, $$v);
80
88
}
81
- }} />;` ,
89
+ }} />;` . trim ( ) ,
82
90
} ,
83
91
]
84
92
0 commit comments