File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ const onItemTap = useDebounceFn((item: Item) => {
114
114
115
115
<ListView :items =" items2" height =" 800" >
116
116
<template #default =" { item , index }: ListItem < Item > " >
117
+ <!-- TEST -->
118
+ <!-- TEST -->
119
+ <!-- TEST -->
120
+ <!-- TEST -->
117
121
<StackLayout
118
122
@tap =" onItemTap(item)"
119
123
:backgroundColor =" selected.includes(item) ? '#ffedd5' : ''"
Original file line number Diff line number Diff line change 6
6
warn ,
7
7
watch ,
8
8
ref ,
9
+ Comment ,
9
10
} from '@vue/runtime-core' ;
10
11
11
12
import {
@@ -128,20 +129,27 @@ export const ListView = /*#__PURE__*/ defineComponent({
128
129
// render all realized templates as children
129
130
const cellVNODES = ( ) =>
130
131
Object . entries ( cells . value ) . map ( ( [ id , entry ] ) => {
131
- const vnodes : VNode [ ] = ctx . slots [ entry . slotName ] ?.( entry . itemCtx ) ?? [
132
- // default template is just a label
133
- h ( 'Label' , {
134
- text : entry . itemCtx . item ,
135
- } ) ,
136
- ] ;
137
-
138
- if ( vnodes . length > 1 ) {
132
+ const vnodes : VNode [ ] =
133
+ ctx . slots [ entry . slotName ] ?.( entry . itemCtx ) ?? [ ] ;
134
+ const nonCommentVnodes = vnodes . filter (
135
+ ( vnode ) => vnode . type !== Comment ,
136
+ ) ;
137
+
138
+ if ( nonCommentVnodes . length === 0 ) {
139
+ warn ( `ListView template must contain at least one element.` ) ;
140
+ } else if ( nonCommentVnodes . length > 1 ) {
139
141
warn (
140
142
`ListView template must contain a single root element. Found: ${ vnodes . length } . Only the first one will be used.` ,
141
143
) ;
142
144
}
143
145
144
- const vnode : VNode = vnodes [ 0 ] ;
146
+ const vnode : VNode =
147
+ nonCommentVnodes . at ( 0 ) ??
148
+ // default template is just a label
149
+ h ( 'Label' , {
150
+ text : entry . itemCtx . item ,
151
+ } ) ;
152
+
145
153
// set the key to the list cell id, so we can find this cell later...
146
154
vnode . key = id ;
147
155
You can’t perform that action at this time.
0 commit comments