@@ -6,56 +6,52 @@ import Vue from 'vue'
66import VueWrapper from './vue-wrapper'
77import createInstance from 'create-instance'
88import createElement from './create-element'
9- import errorHandler from './error-handler'
10- import { findAllInstances } from './find'
9+ import {
10+ throwIfInstancesThrew ,
11+ addGlobalErrorHandler
12+ } from './error'
1113import { mergeOptions } from 'shared/merge-options'
1214import config from './config'
1315import warnIfNoWindow from './warn-if-no-window'
1416import createWrapper from './create-wrapper'
1517import createLocalVue from './create-local-vue'
18+
1619Vue . config . productionTip = false
1720Vue . config . devtools = false
1821
1922export default function mount (
2023 component : Component ,
2124 options : Options = { }
2225) : VueWrapper | Wrapper {
23- const existingErrorHandler = Vue . config . errorHandler
24- Vue . config . errorHandler = errorHandler
25-
2626 warnIfNoWindow ( )
2727
28- const elm = options . attachToDocument ? createElement ( ) : undefined
28+ addGlobalErrorHandler ( Vue )
29+
30+ const _Vue = createLocalVue ( options . localVue )
2931
3032 const mergedOptions = mergeOptions ( options , config )
3133
3234 const parentVm = createInstance (
3335 component ,
3436 mergedOptions ,
35- createLocalVue ( options . localVue )
37+ _Vue
3638 )
3739
38- const vm = parentVm . $mount ( elm ) . $refs . vm
39-
40- const componentsWithError = findAllInstances ( vm ) . filter (
41- c => c . _error
42- )
40+ const el = options . attachToDocument ? createElement ( ) : undefined
41+ const vm = parentVm . $mount ( el ) . $refs . vm
4342
44- if ( componentsWithError . length > 0 ) {
45- throw componentsWithError [ 0 ] . _error
46- }
43+ component . _Ctor = { }
4744
48- Vue . config . errorHandler = existingErrorHandler
45+ throwIfInstancesThrew ( vm )
4946
5047 const wrapperOptions = {
5148 attachedToDocument : ! ! mergedOptions . attachToDocument ,
5249 sync : mergedOptions . sync
5350 }
51+
5452 const root = vm . $options . _isFunctionalContainer
5553 ? vm . _vnode
5654 : vm
5755
58- component . _Ctor = [ ]
59-
6056 return createWrapper ( root , wrapperOptions )
6157}
0 commit comments