File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 8
8
KeepAlive ,
9
9
Suspense ,
10
10
type SuspenseProps ,
11
+ createCommentVNode ,
11
12
h ,
12
13
nextTick ,
13
14
nodeOps ,
@@ -2085,6 +2086,35 @@ describe('Suspense', () => {
2085
2086
expect ( serializeInner ( root ) ) . toBe ( `<div>async2</div>` )
2086
2087
} )
2087
2088
2089
+ test ( 'KeepAlive + Suspense + comment slot' , async ( ) => {
2090
+ const toggle = ref ( false )
2091
+ const Async = defineAsyncComponent ( {
2092
+ render ( ) {
2093
+ return h ( 'div' , 'async1' )
2094
+ } ,
2095
+ } )
2096
+ const App = {
2097
+ render ( ) {
2098
+ return h ( KeepAlive , null , {
2099
+ default : ( ) => {
2100
+ return h ( Suspense , null , {
2101
+ default : toggle . value ? h ( Async ) : createCommentVNode ( 'v-if' ) ,
2102
+ } )
2103
+ } ,
2104
+ } )
2105
+ } ,
2106
+ }
2107
+
2108
+ const root = nodeOps . createElement ( 'div' )
2109
+ render ( h ( App ) , root )
2110
+ expect ( serializeInner ( root ) ) . toBe ( `<!--v-if-->` )
2111
+
2112
+ toggle . value = true
2113
+ await nextTick ( )
2114
+ await Promise . all ( deps )
2115
+ expect ( serializeInner ( root ) ) . toBe ( `<div>async1</div>` )
2116
+ } )
2117
+
2088
2118
// #6416 follow up / #10017
2089
2119
test ( 'Suspense patched during HOC async component re-mount' , async ( ) => {
2090
2120
const key = ref ( 'k' )
Original file line number Diff line number Diff line change 8
8
getCurrentInstance ,
9
9
} from '../component'
10
10
import {
11
+ Comment ,
11
12
type VNode ,
12
13
type VNodeProps ,
13
14
cloneVNode ,
@@ -287,6 +288,12 @@ const KeepAliveImpl: ComponentOptions = {
287
288
}
288
289
289
290
let vnode = getInnerChild ( rawVNode )
291
+ // #6028 Suspense ssContent maybe a comment VNode, should avoid caching it
292
+ if ( vnode . type === Comment ) {
293
+ current = null
294
+ return vnode
295
+ }
296
+
290
297
const comp = vnode . type as ConcreteComponent
291
298
292
299
// for async components, name check should be based in its loaded
You can’t perform that action at this time.
0 commit comments