1
- // @flow
2
-
3
1
import Vue from 'vue'
4
- import VueWrapper from './vue-wrapper'
5
2
import createInstance from 'create-instance'
6
3
import createElement from './create-element'
7
4
import { throwIfInstancesThrew , addGlobalErrorHandler } from './error'
@@ -14,6 +11,8 @@ import { warn } from 'shared/util'
14
11
import semver from 'semver'
15
12
import { COMPAT_SYNC_MODE } from 'shared/consts'
16
13
import { validateOptions } from 'shared/validate-options'
14
+ import TransitionGroupStub from './components/TransitionGroupStub'
15
+ import TransitionStub from './components/TransitionStub'
17
16
18
17
Vue . config . productionTip = false
19
18
Vue . config . devtools = false
@@ -45,20 +44,45 @@ function getSyncOption(syncOption) {
45
44
return true
46
45
}
47
46
48
- export default function mount (
49
- component : Component ,
50
- options : Options = { }
51
- ) : VueWrapper | Wrapper {
47
+ function addTransitionStubs ( options ) {
48
+ if ( config . stubs === false ) {
49
+ return
50
+ }
51
+ if (
52
+ options . stubs &&
53
+ options . stubs . transition !== false &&
54
+ ! options . stubs . transition
55
+ ) {
56
+ options . stubs . transition = TransitionStub
57
+ }
58
+ if (
59
+ options . stubs &&
60
+ options . stubs [ 'transition-group' ] !== false &&
61
+ ! options . stubs [ 'transition-group' ]
62
+ ) {
63
+ options . stubs [ 'transition-group' ] = TransitionGroupStub
64
+ }
65
+ }
66
+
67
+ export default function mount ( component , options = { } ) {
52
68
warnIfNoWindow ( )
53
69
54
70
addGlobalErrorHandler ( Vue )
55
71
56
72
const _Vue = createLocalVue ( options . localVue )
57
73
58
74
const mergedOptions = mergeOptions ( options , config )
75
+ const sync = getSyncOption ( mergedOptions . sync )
59
76
60
77
validateOptions ( mergedOptions , component )
61
78
79
+ // Stub transition and transition-group if in compat sync mode to keep old
80
+ // behavior
81
+ // TODO: Remove when compat sync mode is removed
82
+ if ( sync === COMPAT_SYNC_MODE ) {
83
+ addTransitionStubs ( mergedOptions )
84
+ }
85
+
62
86
const parentVm = createInstance ( component , mergedOptions , _Vue )
63
87
64
88
const el = options . attachToDocument ? createElement ( ) : undefined
@@ -67,7 +91,6 @@ export default function mount(
67
91
component . _Ctor = { }
68
92
69
93
throwIfInstancesThrew ( vm )
70
- const sync = getSyncOption ( mergedOptions . sync )
71
94
72
95
const wrapperOptions = {
73
96
attachedToDocument : ! ! mergedOptions . attachToDocument ,
0 commit comments