@@ -94,6 +94,14 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
94
94
* @deprecated filters have been removed from Vue 3.
95
95
*/
96
96
filter ( name : string , arg : any ) : null
97
+ /**
98
+ * @internal
99
+ */
100
+ cid : number
101
+ /**
102
+ * @internal
103
+ */
104
+ options : ComponentOptions
97
105
98
106
configureCompat : typeof configureCompat
99
107
}
@@ -109,8 +117,6 @@ export function createCompatVue(
109
117
} as any
110
118
111
119
const singletonApp = createApp ( { } )
112
- // @ts -ignore
113
- singletonApp . prototype = singletonApp . config . globalProperties
114
120
115
121
function createCompatApp ( options : ComponentOptions = { } , Ctor : any ) {
116
122
assertCompatEnabled ( DeprecationTypes . GLOBAL_MOUNT , null )
@@ -174,18 +180,26 @@ export function createCompatVue(
174
180
Vue . version = __VERSION__
175
181
Vue . config = singletonApp . config
176
182
Vue . nextTick = nextTick
183
+ Vue . options = { _base : Vue }
184
+
185
+ let cid = 1
186
+ Vue . cid = cid
177
187
178
- Vue . extend = ( ( options : ComponentOptions = { } ) => {
188
+ function extendCtor ( this : any , extendOptions : ComponentOptions = { } ) {
179
189
assertCompatEnabled ( DeprecationTypes . GLOBAL_EXTEND , null )
190
+ if ( isFunction ( extendOptions ) ) {
191
+ extendOptions = extendOptions . options
192
+ }
180
193
194
+ const Super = this
181
195
function SubVue ( inlineOptions ?: ComponentOptions ) {
182
196
if ( ! inlineOptions ) {
183
- return createCompatApp ( options , SubVue )
197
+ return createCompatApp ( extendOptions , SubVue )
184
198
} else {
185
199
return createCompatApp (
186
200
{
187
201
el : inlineOptions . el ,
188
- extends : options ,
202
+ extends : extendOptions ,
189
203
mixins : [ inlineOptions ]
190
204
} ,
191
205
SubVue
@@ -194,8 +208,20 @@ export function createCompatVue(
194
208
}
195
209
SubVue . prototype = Object . create ( Vue . prototype )
196
210
SubVue . prototype . constructor = SubVue
211
+ SubVue . options = mergeOptions (
212
+ extend ( { } , Super . options ) as ComponentOptions ,
213
+ extendOptions
214
+ )
215
+
216
+ SubVue . options . _base = SubVue
217
+ SubVue . extend = extendCtor . bind ( SubVue )
218
+ SubVue . mixin = Super . mixin
219
+ SubVue . use = Super . use
220
+ SubVue . cid = ++ cid
197
221
return SubVue
198
- } ) as any
222
+ }
223
+
224
+ Vue . extend = extendCtor . bind ( Vue ) as any
199
225
200
226
Vue . set = ( target , key , value ) => {
201
227
assertCompatEnabled ( DeprecationTypes . GLOBAL_SET , null )
@@ -213,7 +239,11 @@ export function createCompatVue(
213
239
}
214
240
215
241
Vue . use = ( p , ...options ) => {
216
- singletonApp . use ( p , ...options )
242
+ if ( p && isFunction ( p . install ) ) {
243
+ p . install ( Vue as any , ...options )
244
+ } else if ( isFunction ( p ) ) {
245
+ p ( Vue as any , ...options )
246
+ }
217
247
return Vue
218
248
}
219
249
0 commit comments