@@ -26,13 +26,19 @@ import {
26
26
27
27
import { config } from './config'
28
28
import { GlobalMountOptions } from './types'
29
- import { mergeGlobalProperties } from './utils'
29
+ import {
30
+ isClassComponent ,
31
+ isFunctionalComponent ,
32
+ isObjectComponent ,
33
+ mergeGlobalProperties
34
+ } from './utils'
30
35
import { processSlot } from './utils/compileSlots'
31
36
import { createWrapper , VueWrapper } from './vueWrapper'
32
37
import { attachEmitListener } from './emitMixin'
33
38
import { createDataMixin } from './dataMixin'
34
39
import { MOUNT_COMPONENT_REF , MOUNT_PARENT_NAME } from './constants'
35
40
import { stubComponents } from './stubs'
41
+ import { VueConstructor } from 'vue-class-component'
36
42
37
43
// NOTE this should come from `vue`
38
44
type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps
@@ -67,6 +73,12 @@ export type ObjectEmitsOptions = Record<
67
73
>
68
74
export type EmitsOptions = ObjectEmitsOptions | string [ ]
69
75
76
+ // Class component
77
+ export function mount (
78
+ originalComponent : VueConstructor ,
79
+ options ?: MountingOptions < any >
80
+ ) : VueWrapper < ComponentPublicInstance < any > >
81
+
70
82
// Functional component with emits
71
83
export function mount < Props , E extends EmitsOptions = { } > (
72
84
originalComponent : FunctionalComponent < Props , E > ,
@@ -228,7 +240,7 @@ export function mount(
228
240
229
241
const functionalComponentEmits : Record < string , unknown [ ] > = { }
230
242
231
- if ( typeof originalComponent === 'function' ) {
243
+ if ( isFunctionalComponent ( originalComponent ) ) {
232
244
// we need to wrap it like this so we can capture emitted events.
233
245
// we capture events using a mixin that mutates `emit` in `beforeCreate`,
234
246
// but functional components do not support mixins, so we need to wrap it
@@ -240,8 +252,10 @@ export function mount(
240
252
)
241
253
}
242
254
} )
243
- } else {
255
+ } else if ( isObjectComponent ( originalComponent ) ) {
244
256
component = { ...originalComponent }
257
+ } else {
258
+ component = originalComponent
245
259
}
246
260
247
261
const el = document . createElement ( 'div' )
0 commit comments