@@ -10,50 +10,45 @@ import { throwError } from './util'
10
10
import cloneDeep from 'lodash/cloneDeep'
11
11
import { compileTemplate } from './compile-template'
12
12
import createLocalVue from '../create-local-vue'
13
- import config from '../config '
13
+ import extractOptions from '../options/extract-options '
14
14
15
15
export default function createConstructor (
16
16
component : Component ,
17
17
options : Options
18
18
) : Component {
19
- const vue = options . localVue || createLocalVue ( )
19
+ const mountingOptions = extractOptions ( options )
20
20
21
- if ( options . mocks ) {
22
- addMocks ( options . mocks , vue )
21
+ const vue = mountingOptions . localVue || createLocalVue ( )
22
+
23
+ if ( mountingOptions . mocks ) {
24
+ addMocks ( mountingOptions . mocks , vue )
23
25
}
24
26
25
27
if ( component . functional ) {
26
- if ( options . context && typeof options . context !== 'object' ) {
28
+ if ( mountingOptions . context && typeof mountingOptions . context !== 'object' ) {
27
29
throwError ( 'mount.context must be an object' )
28
30
}
29
31
const clonedComponent = cloneDeep ( component )
30
32
component = {
31
33
render ( h ) {
32
34
return h (
33
35
clonedComponent ,
34
- options . context || component . FunctionalRenderContext
36
+ mountingOptions . context || component . FunctionalRenderContext
35
37
)
36
38
}
37
39
}
38
- } else if ( options . context ) {
40
+ } else if ( mountingOptions . context ) {
39
41
throwError (
40
42
'mount.context can only be used when mounting a functional component'
41
43
)
42
44
}
43
45
44
- if ( options . provide ) {
45
- addProvide ( component , options )
46
+ if ( mountingOptions . provide ) {
47
+ addProvide ( component , mountingOptions . provide , options )
46
48
}
47
49
48
- if ( options . stubs || Object . keys ( config . stubs ) . length > 0 ) {
49
- if ( Array . isArray ( options . stubs ) ) {
50
- stubComponents ( component , options . stubs )
51
- } else {
52
- stubComponents ( component , {
53
- ...config . stubs ,
54
- ...options . stubs
55
- } )
56
- }
50
+ if ( mountingOptions . stubs ) {
51
+ stubComponents ( component , mountingOptions . stubs )
57
52
}
58
53
59
54
if ( ! component . render && component . template && ! component . functional ) {
@@ -64,11 +59,11 @@ export default function createConstructor (
64
59
65
60
const vm = new Constructor ( options )
66
61
67
- addAttrs ( vm , options . attrs )
68
- addListeners ( vm , options . listeners )
62
+ addAttrs ( vm , mountingOptions . attrs )
63
+ addListeners ( vm , mountingOptions . listeners )
69
64
70
- if ( options . slots ) {
71
- addSlots ( vm , options . slots )
65
+ if ( mountingOptions . slots ) {
66
+ addSlots ( vm , mountingOptions . slots )
72
67
}
73
68
74
69
return vm
0 commit comments