@@ -6,56 +6,52 @@ import Vue from 'vue'
6
6
import VueWrapper from './vue-wrapper'
7
7
import createInstance from 'create-instance'
8
8
import createElement from './create-element'
9
- import errorHandler from './error-handler'
10
- import { findAllInstances } from './find'
9
+ import {
10
+ throwIfInstancesThrew ,
11
+ addGlobalErrorHandler
12
+ } from './error'
11
13
import { mergeOptions } from 'shared/merge-options'
12
14
import config from './config'
13
15
import warnIfNoWindow from './warn-if-no-window'
14
16
import createWrapper from './create-wrapper'
15
17
import createLocalVue from './create-local-vue'
18
+
16
19
Vue . config . productionTip = false
17
20
Vue . config . devtools = false
18
21
19
22
export default function mount (
20
23
component : Component ,
21
24
options : Options = { }
22
25
) : VueWrapper | Wrapper {
23
- const existingErrorHandler = Vue . config . errorHandler
24
- Vue . config . errorHandler = errorHandler
25
-
26
26
warnIfNoWindow ( )
27
27
28
- const elm = options . attachToDocument ? createElement ( ) : undefined
28
+ addGlobalErrorHandler ( Vue )
29
+
30
+ const _Vue = createLocalVue ( options . localVue )
29
31
30
32
const mergedOptions = mergeOptions ( options , config )
31
33
32
34
const parentVm = createInstance (
33
35
component ,
34
36
mergedOptions ,
35
- createLocalVue ( options . localVue )
37
+ _Vue
36
38
)
37
39
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
43
42
44
- if ( componentsWithError . length > 0 ) {
45
- throw componentsWithError [ 0 ] . _error
46
- }
43
+ component . _Ctor = { }
47
44
48
- Vue . config . errorHandler = existingErrorHandler
45
+ throwIfInstancesThrew ( vm )
49
46
50
47
const wrapperOptions = {
51
48
attachedToDocument : ! ! mergedOptions . attachToDocument ,
52
49
sync : mergedOptions . sync
53
50
}
51
+
54
52
const root = vm . $options . _isFunctionalContainer
55
53
? vm . _vnode
56
54
: vm
57
55
58
- component . _Ctor = [ ]
59
-
60
56
return createWrapper ( root , wrapperOptions )
61
57
}
0 commit comments