@@ -12,7 +12,7 @@ interface MountingOptions<Props> {
12
12
slots ?: {
13
13
default ?: Slot
14
14
[ key : string ] : Slot
15
- } ,
15
+ }
16
16
plugins ?: any [ ]
17
17
mixins ?: any [ ]
18
18
provides ?: Record < any , any >
@@ -23,26 +23,30 @@ export function mount<P>(
23
23
component : any ,
24
24
options ?: MountingOptions < P >
25
25
) : VueWrapper {
26
-
27
26
// Reset the document.body
28
- document . getElementsByTagName ( 'html' ) [ 0 ] . innerHTML = '' ;
27
+ document . getElementsByTagName ( 'html' ) [ 0 ] . innerHTML = ''
29
28
const el = document . createElement ( 'div' )
30
29
el . id = 'app'
31
30
document . body . appendChild ( el )
32
31
33
32
// handle any slots passed via mounting options
34
- const slots = options ?. slots &&
35
- Object . entries ( options . slots ) . reduce < Record < string , ( ) => VNode | string > > ( ( acc , [ name , fn ] ) => {
36
- acc [ name ] = ( ) => fn
37
- return acc
38
- } , { } )
33
+ const slots =
34
+ options ?. slots &&
35
+ Object . entries ( options . slots ) . reduce < Record < string , ( ) => VNode | string > > (
36
+ ( acc , [ name , fn ] ) => {
37
+ acc [ name ] = ( ) => fn
38
+ return acc
39
+ } ,
40
+ { }
41
+ )
39
42
40
43
// create the wrapper component
41
- const Parent = ( props ?: P ) => defineComponent ( {
42
- render ( ) {
43
- return h ( component , props , slots )
44
- }
45
- } )
44
+ const Parent = ( props ?: P ) =>
45
+ defineComponent ( {
46
+ render ( ) {
47
+ return h ( component , props , slots )
48
+ }
49
+ } )
46
50
47
51
// create the vm
48
52
const vm = createApp ( Parent ( options && options . props ) )
@@ -55,17 +59,14 @@ export function mount<P>(
55
59
56
60
// use and plugins from mounting options
57
61
if ( options ?. plugins ) {
58
- for ( const use of options . plugins )
59
- vm . use ( use )
62
+ for ( const use of options . plugins ) vm . use ( use )
60
63
}
61
64
62
65
// use any mixins from mounting options
63
66
if ( options ?. mixins ) {
64
- for ( const mixin of options . mixins )
65
- vm . mixin ( mixin )
67
+ for ( const mixin of options . mixins ) vm . mixin ( mixin )
66
68
}
67
69
68
-
69
70
// provide any values passed via provides mounting option
70
71
if ( options ?. provides ) {
71
72
for ( const key of Reflect . ownKeys ( options . provides ) ) {
@@ -82,4 +83,4 @@ export function mount<P>(
82
83
const app = vm . mount ( '#app' )
83
84
84
85
return createWrapper ( app , events )
85
- }
86
+ }
0 commit comments