@@ -43,7 +43,6 @@ describe('compiler: template ref transform', () => {
43
43
} ,
44
44
} ,
45
45
} )
46
-
47
46
expect ( code ) . matchSnapshot ( )
48
47
expect ( code ) . contains ( '_setRef(n0, "foo")' )
49
48
} )
@@ -56,21 +55,28 @@ describe('compiler: template ref transform', () => {
56
55
flags : DynamicFlag . REFERENCED ,
57
56
} )
58
57
expect ( ir . template ) . toEqual ( [ '<div></div>' ] )
59
- expect ( ir . block . operation ) . lengthOf ( 1 )
60
- expect ( ir . block . operation [ 0 ] ) . toMatchObject ( {
61
- type : IRNodeTypes . SET_TEMPLATE_REF ,
62
- element : 0 ,
63
- value : {
64
- content : 'foo' ,
65
- isStatic : false ,
66
- loc : {
67
- start : { line : 1 , column : 12 , offset : 11 } ,
68
- end : { line : 1 , column : 15 , offset : 14 } ,
69
- } ,
58
+ expect ( ir . block . operation ) . toMatchObject ( [
59
+ {
60
+ type : IRNodeTypes . DECLARE_OLD_REF ,
61
+ id : 0 ,
70
62
} ,
71
- } )
63
+ ] )
64
+ expect ( ir . block . effect ) . toMatchObject ( [
65
+ {
66
+ operations : [
67
+ {
68
+ type : IRNodeTypes . SET_TEMPLATE_REF ,
69
+ element : 0 ,
70
+ value : {
71
+ content : 'foo' ,
72
+ isStatic : false ,
73
+ } ,
74
+ } ,
75
+ ] ,
76
+ } ,
77
+ ] )
72
78
expect ( code ) . matchSnapshot ( )
73
- expect ( code ) . contains ( '_setRef(n0, _ctx.foo)' )
79
+ expect ( code ) . contains ( '_setRef(n0, _ctx.foo, r0 )' )
74
80
} )
75
81
76
82
test ( 'ref + v-if' , ( ) => {
@@ -82,21 +88,17 @@ describe('compiler: template ref transform', () => {
82
88
expect ( ir . block . operation [ 0 ] . type ) . toBe ( IRNodeTypes . IF )
83
89
84
90
const { positive } = ir . block . operation [ 0 ] as IfIRNode
85
-
86
- expect ( positive . operation ) . lengthOf ( 1 )
87
- expect ( positive . operation [ 0 ] ) . toMatchObject ( {
88
- type : IRNodeTypes . SET_TEMPLATE_REF ,
89
- element : 2 ,
90
- value : {
91
- content : 'foo' ,
92
- isStatic : true ,
93
- loc : {
94
- start : { line : 1 , column : 10 , offset : 9 } ,
95
- end : { line : 1 , column : 15 , offset : 14 } ,
91
+ expect ( positive . operation ) . toMatchObject ( [
92
+ {
93
+ type : IRNodeTypes . SET_TEMPLATE_REF ,
94
+ element : 2 ,
95
+ value : {
96
+ content : 'foo' ,
97
+ isStatic : true ,
96
98
} ,
99
+ effect : false ,
97
100
} ,
98
- } )
99
-
101
+ ] )
100
102
expect ( code ) . matchSnapshot ( )
101
103
expect ( code ) . contains ( '_setRef(n2, "foo")' )
102
104
} )
@@ -107,21 +109,19 @@ describe('compiler: template ref transform', () => {
107
109
)
108
110
109
111
const { render } = ir . block . operation [ 0 ] as ForIRNode
110
- expect ( render . operation ) . lengthOf ( 1 )
111
- expect ( render . operation [ 0 ] ) . toMatchObject ( {
112
- type : IRNodeTypes . SET_TEMPLATE_REF ,
113
- element : 2 ,
114
- value : {
115
- content : 'foo' ,
116
- isStatic : true ,
117
- loc : {
118
- start : { line : 1 , column : 10 , offset : 9 } ,
119
- end : { line : 1 , column : 15 , offset : 14 } ,
112
+ expect ( render . operation ) . toMatchObject ( [
113
+ {
114
+ type : IRNodeTypes . SET_TEMPLATE_REF ,
115
+ element : 2 ,
116
+ value : {
117
+ content : 'foo' ,
118
+ isStatic : true ,
120
119
} ,
120
+ refFor : true ,
121
+ effect : false ,
121
122
} ,
122
- refFor : true ,
123
- } )
123
+ ] )
124
124
expect ( code ) . matchSnapshot ( )
125
- expect ( code ) . contains ( '_setRef(n2, "foo", true)' )
125
+ expect ( code ) . contains ( '_setRef(n2, "foo", void 0, true)' )
126
126
} )
127
127
} )
0 commit comments