@@ -10,50 +10,45 @@ import { throwError } from './util'
1010import cloneDeep from 'lodash/cloneDeep'
1111import { compileTemplate } from './compile-template'
1212import createLocalVue from '../create-local-vue'
13- import config from '../config '
13+ import extractOptions from '../options/extract-options '
1414
1515export default function createConstructor (
1616 component : Component ,
1717 options : Options
1818) : Component {
19- const vue = options . localVue || createLocalVue ( )
19+ const mountingOptions = extractOptions ( options )
2020
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 )
2325 }
2426
2527 if ( component . functional ) {
26- if ( options . context && typeof options . context !== 'object' ) {
28+ if ( mountingOptions . context && typeof mountingOptions . context !== 'object' ) {
2729 throwError ( 'mount.context must be an object' )
2830 }
2931 const clonedComponent = cloneDeep ( component )
3032 component = {
3133 render ( h ) {
3234 return h (
3335 clonedComponent ,
34- options . context || component . FunctionalRenderContext
36+ mountingOptions . context || component . FunctionalRenderContext
3537 )
3638 }
3739 }
38- } else if ( options . context ) {
40+ } else if ( mountingOptions . context ) {
3941 throwError (
4042 'mount.context can only be used when mounting a functional component'
4143 )
4244 }
4345
44- if ( options . provide ) {
45- addProvide ( component , options )
46+ if ( mountingOptions . provide ) {
47+ addProvide ( component , mountingOptions . provide , options )
4648 }
4749
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 )
5752 }
5853
5954 if ( ! component . render && component . template && ! component . functional ) {
@@ -64,11 +59,11 @@ export default function createConstructor (
6459
6560 const vm = new Constructor ( options )
6661
67- addAttrs ( vm , options . attrs )
68- addListeners ( vm , options . listeners )
62+ addAttrs ( vm , mountingOptions . attrs )
63+ addListeners ( vm , mountingOptions . listeners )
6964
70- if ( options . slots ) {
71- addSlots ( vm , options . slots )
65+ if ( mountingOptions . slots ) {
66+ addSlots ( vm , mountingOptions . slots )
7267 }
7368
7469 return vm
0 commit comments