@@ -41,9 +41,9 @@ describe('compiler: transform v-slot', () => {
41
41
)
42
42
assert (
43
43
`<unicloud-db v-slot:default="{data, loading, error, options}"><view v-if="error">{{error.message}}</view><view v-else></view></unicloud-db>` ,
44
- `<unicloud-db u-s="{{b }}" u-i="2a9ec0b0-0"><view wx:for="{{a}}" wx:for-item="v0" wx:key="c" slot="{{v0.d}}"><view wx:if="{{v0.a}}">{{v0.b}}</view><view wx:else></view></view></unicloud-db>` ,
44
+ `<unicloud-db u-s="{{['d'] }}" u-i="2a9ec0b0-0"><view wx:for="{{a}}" wx:for-item="v0" wx:key="c" slot="{{v0.d}}"><view wx:if="{{v0.a}}">{{v0.b}}</view><view wx:else></view></view></unicloud-db>` ,
45
45
`(_ctx, _cache) => {
46
- return { a: _w(({ data, loading, error, options }, s0, i0) => { return _e({ a: error }, error ? { b: _t(error.message) } : {}, { c: i0, d: s0 }); }, { name: 'd', path: 'a', vueId: '2a9ec0b0-0' }), b: [_ctx.error ? "d" : "true" ? "d" : "" ? 'd' : ''] }
46
+ return { a: _w(({ data, loading, error, options }, s0, i0) => { return _e({ a: error }, error ? { b: _t(error.message) } : {}, { c: i0, d: s0 }); }, { name: 'd', path: 'a', vueId: '2a9ec0b0-0' }) }
47
47
}`
48
48
)
49
49
} )
@@ -201,6 +201,14 @@ describe('v-slot + v-if / v-else-if / v-else', () => {
201
201
}`
202
202
)
203
203
204
+ assert (
205
+ `<custom><template v-if="a">hello</template><template v-else #footer>hello</template></custom>` ,
206
+ `<custom u-s="{{b}}" u-i="2a9ec0b0-0"><block wx:if="{{a}}">hello</block><view wx:else slot="footer">hello</view></custom>` ,
207
+ `(_ctx, _cache) => {
208
+ return _e({ a: _ctx.a }, _ctx.a ? {} : {}, { b: [_ctx.a ? "d" : "true" ? 'footer' : '', _ctx.a ? 'd' : ''] })
209
+ }`
210
+ )
211
+
204
212
assert (
205
213
`<custom><template v-if="a" #header>hello</template><template v-if="b" #footer>hello</template></custom>` ,
206
214
`<custom u-s="{{c}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:if="{{b}}" slot="footer">hello</view></custom>` ,
@@ -221,47 +229,55 @@ describe('v-slot + v-if / v-else-if / v-else', () => {
221
229
`<custom><template v-if="a" #header>hello</template><template v-else #footer>hello</template></custom>` ,
222
230
`<custom u-s="{{b}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:else slot="footer">hello</view></custom>` ,
223
231
`(_ctx, _cache) => {
224
- return _e({ a: _ctx.a }, _ctx.a ? {} : {}, { b: [_ctx.a ? 'header' : '', _ctx.a ? "header" : "true" ? "footer" : "" ? 'footer' : ''] })
232
+ return _e({ a: _ctx.a }, _ctx.a ? {} : {}, { b: [_ctx.a ? 'header' : '', _ctx.a ? "header" : "true" ? 'footer' : ''] })
225
233
}`
226
234
)
227
235
228
236
assert (
229
237
`<custom><template v-if="a" #header>hello</template><template v-else>hello</template></custom>` ,
230
238
`<custom u-s="{{b}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><block wx:else>hello</block></custom>` ,
231
239
`(_ctx, _cache) => {
232
- return _e({ a: _ctx.a }, _ctx.a ? {} : {}, { b: [_ctx.a ? 'header' : '', _ctx.a ? "header" : "true" ? "d" : "" ? 'd' : ''] })
240
+ return _e({ a: _ctx.a }, _ctx.a ? {} : {}, { b: [_ctx.a ? 'header' : '', _ctx.a ? "header" : "true" ? 'd' : ''] })
233
241
}`
234
242
)
235
243
236
244
assert (
237
245
`<custom><template v-if="a" #header>hello</template><template v-else-if="b" #footer>hello</template></custom>` ,
238
246
`<custom u-s="{{c}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:elif="{{b}}" slot="footer">hello</view></custom>` ,
239
247
`(_ctx, _cache) => {
240
- return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? 'footer' : ''] })
248
+ return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? 'footer' : ''] })
241
249
}`
242
250
)
243
251
244
252
assert (
245
253
`<custom><template v-if="a" #header>hello</template><template v-else-if="b" #footer>hello</template><template v-else-if="c" #header2>hello</template></custom>` ,
246
254
`<custom u-s="{{d}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:elif="{{b}}" slot="footer">hello</view><view wx:elif="{{c}}" slot="header2">hello</view></custom>` ,
247
255
`(_ctx, _cache) => {
248
- return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : _ctx.c ? {} : {}, { b: _ctx.b, c: _ctx.c, d: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? 'footer' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : _ctx.c ? "header2" : "" ? 'header2' : ''] })
256
+ return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : _ctx.c ? {} : {}, { b: _ctx.b, c: _ctx.c, d: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? 'footer' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : _ctx.c ? 'header2' : ''] })
249
257
}`
250
258
)
251
259
252
260
assert (
253
261
`<custom><template v-if="a" #header>hello</template><template v-else-if="b" #footer>hello</template><template v-if="c" #header2>hello</template></custom>` ,
254
262
`<custom u-s="{{d}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:elif="{{b}}" slot="footer">hello</view><view wx:if="{{c}}" slot="header2">hello</view></custom>` ,
255
263
`(_ctx, _cache) => {
256
- return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: _ctx.c }, _ctx.c ? {} : {}, { d: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? 'footer' : '', _ctx.c ? 'header2' : ''] })
264
+ return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: _ctx.c }, _ctx.c ? {} : {}, { d: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? 'footer' : '', _ctx.c ? 'header2' : ''] })
257
265
}`
258
266
)
259
267
260
268
assert (
261
269
`<custom><template v-if="a" #header>hello</template><template v-else-if="b" #footer>hello</template><template v-else #footer2>hello</template></custom>` ,
262
270
`<custom u-s="{{c}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:elif="{{b}}" slot="footer">hello</view><view wx:else slot="footer2">hello</view></custom>` ,
263
271
`(_ctx, _cache) => {
264
- return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? 'footer' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : "true" ? "footer2" : "" ? 'footer2' : ''] })
272
+ return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : {}, { b: _ctx.b, c: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? 'footer' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : "true" ? 'footer2' : ''] })
273
+ }`
274
+ )
275
+
276
+ assert (
277
+ `<custom><template v-if="a" #header>hello</template><template v-else-if="b" #footer>hello</template><template v-else-if="c" #footer3>hello</template><template v-else #footer2>hello</template></custom>` ,
278
+ `<custom u-s="{{d}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="header">hello</view><view wx:elif="{{b}}" slot="footer">hello</view><view wx:elif="{{c}}" slot="footer3">hello</view><view wx:else slot="footer2">hello</view></custom>` ,
279
+ `(_ctx, _cache) => {
280
+ return _e({ a: _ctx.a }, _ctx.a ? {} : _ctx.b ? {} : _ctx.c ? {} : {}, { b: _ctx.b, c: _ctx.c, d: [_ctx.a ? 'header' : '', _ctx.a ? "header" : _ctx.b ? 'footer' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : _ctx.c ? 'footer3' : '', _ctx.a ? "header" : _ctx.b ? "footer" : "" ? "footer" : _ctx.c ? "footer3" : "" ? "footer3" : "true" ? 'footer2' : ''] })
265
281
}`
266
282
)
267
283
@@ -277,7 +293,7 @@ describe('v-slot + v-if / v-else-if / v-else', () => {
277
293
`<custom><template v-if="a" #[header]>hello</template><template v-else>hello</template></custom>` ,
278
294
`<custom u-s="{{c}}" u-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="{{b}}">hello</view><block wx:else>hello</block></custom>` ,
279
295
`(_ctx, _cache) => {
280
- return _e({ a: _ctx.a }, _ctx.a ? { b: _d(_ctx.header) } : {}, { c: _d([_ctx.a ? _ctx.header : "", _ctx.a ? _ctx.header : "true" ? "d" : "" ? "d" : "" ]) })
296
+ return _e({ a: _ctx.a }, _ctx.a ? { b: _d(_ctx.header) } : {}, { c: _d([_ctx.a ? _ctx.header : "", _ctx.a ? _ctx.header : "true" ? "d" : ""]) })
281
297
}`
282
298
)
283
299
} )
0 commit comments