@@ -117,7 +117,7 @@ return { ref }
117
117
`;
118
118
119
119
exports[`SFC compile <script setup > inlineTemplate mode avoid unref() when necessary 1`] = `
120
- "import { createVNode as _createVNode , unref as _unref , toDisplayString as _toDisplayString , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
120
+ "import { createVNode as _createVNode , toDisplayString as _toDisplayString , unref as _unref , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
121
121
122
122
import { ref } from 'vue'
123
123
import Foo from './Foo.vue'
@@ -129,12 +129,14 @@ export default {
129
129
130
130
const count = ref(0)
131
131
const constant = {}
132
+ const maybe = foo()
133
+ let lett = 1
132
134
function fn() {}
133
135
134
136
return (_ctx , _cache ) => {
135
137
return (_openBlock (), _createBlock (_Fragment , null , [
136
138
_createVNode (Foo ),
137
- _createVNode (\\" div\\ " , { onClick: fn }, _toDisplayString (_unref (count )) + \\" \\ " + _toDisplayString (constant ) + \\" \\ " + _toDisplayString (_unref (other )), 1 /* TEXT */ )
139
+ _createVNode (\\" div\\ " , { onClick: fn }, _toDisplayString (count . value ) + \\ " \\ " + _toDisplayString ( constant ) + \\ " \\ " + _toDisplayString ( _unref (maybe )) + \\" \\ " + _toDisplayString (_unref ( lett ) ) + \\" \\ " + _toDisplayString (_unref (other )), 1 /* TEXT */ )
138
140
], 64 /* STABLE_FRAGMENT */ ))
139
141
}
140
142
}
@@ -143,7 +145,7 @@ return (_ctx, _cache) => {
143
145
`;
144
146
145
147
exports[`SFC compile <script setup > inlineTemplate mode should work 1`] = `
146
- "import { unref as _unref , toDisplayString as _toDisplayString , createVNode as _createVNode , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
148
+ "import { toDisplayString as _toDisplayString , createVNode as _createVNode , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
147
149
148
150
const _hoisted_1 = /*#__PURE__*/_createVNode(\\"div\\", null, \\"static\\", -1 /* HOISTED */)
149
151
@@ -157,7 +159,7 @@ export default {
157
159
158
160
return (_ctx , _cache ) => {
159
161
return (_openBlock (), _createBlock (_Fragment , null , [
160
- _createVNode (\\" div\\ " , null , _toDisplayString (_unref ( count ) ), 1 /* TEXT */ ),
162
+ _createVNode (\\" div\\ " , null , _toDisplayString (count . value ), 1 /* TEXT */ ),
161
163
_hoisted_1
162
164
], 64 /* STABLE_FRAGMENT */ ))
163
165
}
@@ -167,7 +169,7 @@ return (_ctx, _cache) => {
167
169
`;
168
170
169
171
exports[`SFC compile <script setup > inlineTemplate mode template assignment expression codegen 1`] = `
170
- "import { createVNode as _createVNode , isRef as _isRef , unref as _unref , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
172
+ "import { createVNode as _createVNode , isRef as _isRef , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
171
173
172
174
import { ref } from 'vue'
173
175
@@ -185,10 +187,42 @@ return (_ctx, _cache) => {
185
187
onClick: _cache [1 ] || (_cache [1 ] = $event => (count .value = 1 ))
186
188
}),
187
189
_createVNode (\\" div\\ " , {
188
- onClick: _cache [2 ] || (_cache [2 ] = $event => (! _isRef (maybe ) ? null : maybe .value = _unref (count )))
190
+ onClick: _cache [2 ] || (_cache [2 ] = $event => (maybe .value = count .value ))
191
+ }),
192
+ _createVNode (\\" div\\ " , {
193
+ onClick: _cache [3 ] || (_cache [3 ] = $event => (_isRef (lett ) ? lett .value = count .value : lett = count .value ))
194
+ })
195
+ ], 64 /* STABLE_FRAGMENT */ ))
196
+ }
197
+ }
198
+
199
+ } "
200
+ `;
201
+
202
+ exports[`SFC compile <script setup > inlineTemplate mode template destructure assignment codegen 1`] = `
203
+ "import { createVNode as _createVNode , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
204
+
205
+ import { ref } from 'vue'
206
+
207
+ export default {
208
+ expose : [],
209
+ setup (__props ) {
210
+
211
+ const val = {}
212
+ const count = ref (0 )
213
+ const maybe = foo ()
214
+ let lett = 1
215
+
216
+ return (_ctx , _cache ) => {
217
+ return (_openBlock (), _createBlock (_Fragment , null , [
218
+ _createVNode (\\" div\\ " , {
219
+ onClick: _cache [1 ] || (_cache [1 ] = $event => (({ count: count .value } = val )))
220
+ }),
221
+ _createVNode (\\" div\\ " , {
222
+ onClick: _cache [2 ] || (_cache [2 ] = $event => ([maybe .value ] = val ))
189
223
}),
190
224
_createVNode (\\" div\\ " , {
191
- onClick: _cache [3 ] || (_cache [3 ] = $event => (_isRef ( lett ) ? lett . value = _unref ( count ) : lett = _unref ( count )))
225
+ onClick: _cache [3 ] || (_cache [3 ] = $event => (({ lett: lett } = val )))
192
226
})
193
227
], 64 /* STABLE_FRAGMENT */ ))
194
228
}
@@ -219,10 +253,10 @@ return (_ctx, _cache) => {
219
253
onClick: _cache [2 ] || (_cache [2 ] = $event => (-- count .value ))
220
254
}),
221
255
_createVNode (\\" div\\ " , {
222
- onClick: _cache [3 ] || (_cache [3 ] = $event => (! _isRef ( maybe ) ? null : maybe .value ++ ))
256
+ onClick: _cache [3 ] || (_cache [3 ] = $event => (maybe .value ++ ))
223
257
}),
224
258
_createVNode (\\" div\\ " , {
225
- onClick: _cache [4 ] || (_cache [4 ] = $event => (! _isRef ( maybe ) ? null : -- maybe .value ))
259
+ onClick: _cache [4 ] || (_cache [4 ] = $event => (-- maybe .value ))
226
260
}),
227
261
_createVNode (\\" div\\ " , {
228
262
onClick: _cache [5 ] || (_cache [5 ] = $event => (_isRef (lett ) ? lett .value ++ : lett ++ ))
@@ -238,7 +272,7 @@ return (_ctx, _cache) => {
238
272
`;
239
273
240
274
exports[`SFC compile <script setup > inlineTemplate mode v-model codegen 1`] = `
241
- "import { unref as _unref , vModelText as _vModelText , createVNode as _createVNode , withDirectives as _withDirectives , isRef as _isRef , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
275
+ "import { vModelText as _vModelText , createVNode as _createVNode , withDirectives as _withDirectives , unref as _unref , isRef as _isRef , Fragment as _Fragment , openBlock as _openBlock , createBlock as _createBlock } from \\"vue\\"
242
276
243
277
import { ref } from 'vue'
244
278
@@ -255,7 +289,7 @@ return (_ctx, _cache) => {
255
289
_withDirectives (_createVNode (\\" input\\ " , {
256
290
\\" onUpdate:modelValue\\ " : _cache [1 ] || (_cache [1 ] = $event => (count .value = $event ))
257
291
}, null , 512 /* NEED_PATCH */ ), [
258
- [_vModelText , _unref ( count ) ]
292
+ [_vModelText , count . value ]
259
293
]),
260
294
_withDirectives (_createVNode (\\" input\\ " , {
261
295
\\" onUpdate:modelValue\\ " : _cache [2 ] || (_cache [2 ] = $event => (_isRef (maybe ) ? maybe .value = $event : null ))
@@ -364,6 +398,8 @@ export default {
364
398
a .value = a .value + 1
365
399
b .value .count ++
366
400
b .value .count = b .value .count + 1
401
+ ;({ a: a .value } = { a: 2 })
402
+ ;[a .value ] = [1 ]
367
403
}
368
404
369
405
return { a , b , inc }
0 commit comments