@@ -16,7 +16,6 @@ import { componentNeedsCompiling, isPlainObject } from 'shared/validators'
16
16
import { validateSlots } from './validate-slots'
17
17
import createScopedSlots from './create-scoped-slots'
18
18
import { extendExtendedComponents } from './extend-extended-components'
19
- import Vue from 'vue'
20
19
21
20
function vueExtendUnsupportedOption ( option : string ) {
22
21
return `options.${ option } is not supported for ` +
@@ -36,15 +35,12 @@ const UNSUPPORTED_VERSION_OPTIONS = [
36
35
37
36
export default function createInstance (
38
37
component : Component ,
39
- options : Options
38
+ options : Options ,
39
+ _Vue : Component
40
40
) : Component {
41
41
// Remove cached constructor
42
42
delete component . _Ctor
43
43
44
- const _Vue = options . localVue
45
- ? options . localVue . extend ( )
46
- : Vue . extend ( )
47
-
48
44
// make sure all extends are based on this instance
49
45
_Vue . options . _base = _Vue
50
46
@@ -75,7 +71,8 @@ export default function createInstance (
75
71
component = createFunctionalComponent ( component , options )
76
72
} else if ( options . context ) {
77
73
throwError (
78
- `mount.context can only be used when mounting a ` + `functional component`
74
+ `mount.context can only be used when mounting a ` +
75
+ `functional component`
79
76
)
80
77
}
81
78
@@ -84,13 +81,15 @@ export default function createInstance (
84
81
}
85
82
86
83
// Replace globally registered components with components extended
87
- // from localVue. This makes sure the beforeMount mixins to add stubs
88
- // is applied to globally registered components.
84
+ // from localVue.
89
85
// Vue version must be 2.3 or greater, because of a bug resolving
90
86
// extended constructor options (https://github.com/vuejs/vue/issues/4976)
91
87
if ( vueVersion > 2.2 ) {
92
88
for ( const c in _Vue . options . components ) {
93
89
if ( ! isRequiredComponent ( c ) ) {
90
+ const extendedComponent = _Vue . extend ( _Vue . options . components [ c ] )
91
+ extendedComponent . options . $_vueTestUtils_original =
92
+ _Vue . options . components [ c ]
94
93
_Vue . component ( c , _Vue . extend ( _Vue . options . components [ c ] ) )
95
94
}
96
95
}
0 commit comments