File tree Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Expand file tree Collapse file tree 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -75,19 +75,11 @@ export class VueWrapper<
75
75
// if the subtree is an array of children, we have multiple root nodes
76
76
if ( subTree . shapeFlag === ShapeFlags . ARRAY_CHILDREN ) return true
77
77
78
- if ( subTree . shapeFlag & ShapeFlags . STATEFUL_COMPONENT ) {
78
+ if (
79
+ subTree . shapeFlag & ShapeFlags . STATEFUL_COMPONENT ||
80
+ subTree . shapeFlag & ShapeFlags . FUNCTIONAL_COMPONENT
81
+ ) {
79
82
// Component has multiple children or slot with multiple children
80
- if (
81
- subTree . shapeFlag & ShapeFlags . ARRAY_CHILDREN ||
82
- subTree . shapeFlag & ShapeFlags . SLOTS_CHILDREN
83
- ) {
84
- return true
85
- }
86
-
87
- if ( subTree . component ?. subTree ) {
88
- return checkTree ( subTree . component . subTree )
89
- }
90
- } else if ( subTree . shapeFlag & ShapeFlags . FUNCTIONAL_COMPONENT ) {
91
83
if ( subTree . shapeFlag & ShapeFlags . ARRAY_CHILDREN ) {
92
84
return true
93
85
}
Original file line number Diff line number Diff line change @@ -24,6 +24,21 @@ describe('element', () => {
24
24
expect ( wrapper . element . nodeName ) . toBe ( 'DIV' )
25
25
} )
26
26
27
+ it ( 'returns the VTU root element when mounting component with slot' , ( ) => {
28
+ const NestedComponent = defineComponent ( {
29
+ template : `<h1><slot></slot></h1>`
30
+ } )
31
+
32
+ const RootComponent = defineComponent ( {
33
+ components : { NestedComponent } ,
34
+ template : `<nested-component>test</nested-component>`
35
+ } )
36
+ const wrapper = mount ( RootComponent )
37
+
38
+ expect ( wrapper . element . tagName ) . toBe ( 'H1' )
39
+ expect ( wrapper . html ( ) ) . toBe ( '<h1>test</h1>' )
40
+ } )
41
+
27
42
it ( 'returns the VTU root element when mounting multiple root nodes' , ( ) => {
28
43
const wrapper = mount ( MultiRootText )
29
44
You can’t perform that action at this time.
0 commit comments