File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ import { isNotNullOrUndefined } from '../utils'
3
3
import { VNode , VNodeArrayChildren } from 'vue'
4
4
5
5
export function getRootNodes ( vnode : VNode ) : Node [ ] {
6
- if ( vnode . shapeFlag & ( ShapeFlags . ELEMENT | ShapeFlags . SUSPENSE ) ) {
6
+ if ( vnode . shapeFlag & ShapeFlags . ELEMENT ) {
7
7
return [ vnode . el as Node ]
8
8
} else if ( vnode . shapeFlag & ShapeFlags . COMPONENT ) {
9
9
const { subTree } = vnode . component !
10
10
return getRootNodes ( subTree )
11
+ } else if ( vnode . shapeFlag & ShapeFlags . SUSPENSE ) {
12
+ return getRootNodes ( vnode . suspense ! . activeBranch ! )
11
13
} else if (
12
14
vnode . shapeFlag &
13
15
( ShapeFlags . TEXT_CHILDREN | ShapeFlags . TELEPORT )
Original file line number Diff line number Diff line change 1
1
import SuspenseComponent from '../components/Suspense.vue'
2
2
import { mount , flushPromises } from '../../src'
3
+ import { defineComponent } from 'vue'
3
4
4
5
let mockShouldError = false
5
6
jest . mock ( '../utils' , ( ) => ( {
@@ -32,4 +33,30 @@ describe('suspense', () => {
32
33
33
34
expect ( wrapper . html ( ) ) . toContain ( 'Error!' )
34
35
} )
36
+
37
+ test ( 'returns the element if it is a multi root element inside Suspense' , ( ) => {
38
+ const Async = defineComponent ( {
39
+ template : '<h1>Hello</h1><span id="my-span">There</span>'
40
+ } )
41
+ const Component = defineComponent ( {
42
+ components : { Async } ,
43
+ template : '<Suspense><Async/></Suspense>'
44
+ } )
45
+
46
+ const wrapper = mount ( Component )
47
+ expect ( wrapper . get ( '#my-span' ) ) . not . toBeNull ( )
48
+ } )
49
+
50
+ test ( 'returns the element if it is a root element inside Suspense' , ( ) => {
51
+ const Async = defineComponent ( {
52
+ template : '<div><h1>Hello</h1><span id="my-span">There</span></div>'
53
+ } )
54
+ const Component = defineComponent ( {
55
+ components : { Async } ,
56
+ template : '<Suspense><Async/></Suspense>'
57
+ } )
58
+
59
+ const wrapper = mount ( Component )
60
+ expect ( wrapper . get ( '#my-span' ) ) . not . toBeNull ( )
61
+ } )
35
62
} )
You can’t perform that action at this time.
0 commit comments