6
6
</slot >
7
7
</div >
8
8
<div class =" infinite-status-prompt" v-show =" isNoResults" >
9
- <slot name =" no-results" v-text = " slots.noResults" > </slot >
9
+ <slot name =" no-results" >{{ slots.noResults }} </slot >
10
10
</div >
11
11
<div class =" infinite-status-prompt" v-show =" isNoMore" >
12
- <slot name =" no-more" v-text = " slots.noMore" > </slot >
12
+ <slot name =" no-more" >{{ slots.noMore }} </slot >
13
13
</div >
14
14
</div >
15
15
</template >
18
18
import Spinner from ' ./Spinner.vue' ;
19
19
import config , { evt3rdArg , WARNINGS , ERRORS } from ' ../config' ;
20
20
21
+ /**
22
+ * determine slot is or not a empty element
23
+ * @param {Slot} slot target slot
24
+ * @return {Boolean}
25
+ */
26
+ function isBlankSlotElm (slot ) {
27
+ return (
28
+ slot
29
+ && slot[0 ].elm
30
+ && slot[0 ].elm .textContent === ' '
31
+ && slot[0 ].elm .childNodes .length === 0
32
+ );
33
+ }
34
+
21
35
export default {
22
36
name: ' InfiniteLoading' ,
23
37
data () {
@@ -42,19 +56,23 @@ export default {
42
56
isNoResults: {
43
57
cache: false , // disable cache to fix the problem of get slot text delay
44
58
get () {
45
- const noResultsSlot = this .$slots [' no-results' ];
46
- const isBlankNoResultsSlot = (noResultsSlot && noResultsSlot[0 ].elm && noResultsSlot[0 ].elm .textContent === ' ' );
47
-
48
- return ! this .isLoading && this .isComplete && this .isFirstLoad && ! isBlankNoResultsSlot;
59
+ return (
60
+ ! this .isLoading
61
+ && this .isComplete
62
+ && this .isFirstLoad
63
+ && ! isBlankSlotElm (this .$slots [' no-results' ])
64
+ );
49
65
},
50
66
},
51
67
isNoMore: {
52
68
cache: false , // disable cache to fix the problem of get slot text delay
53
69
get () {
54
- const noMoreSlot = this .$slots [' no-more' ];
55
- const isBlankNoMoreSlot = (noMoreSlot && noMoreSlot[0 ].elm && noMoreSlot[0 ].elm .textContent === ' ' );
56
-
57
- return ! this .isLoading && this .isComplete && ! this .isFirstLoad && ! isBlankNoMoreSlot;
70
+ return (
71
+ ! this .isLoading
72
+ && this .isComplete
73
+ && ! this .isFirstLoad
74
+ && ! isBlankSlotElm (this .$slots [' no-more' ])
75
+ );
58
76
},
59
77
},
60
78
},
0 commit comments