File tree 2 files changed +24
-9
lines changed
test/unit/features/global-api
2 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
- import Vue from '../instance/index'
4
3
import config from '../config'
5
4
import { warn } from './debug'
6
5
import { set } from '../observer/index'
@@ -275,21 +274,20 @@ export function mergeOptions (
275
274
if ( process . env . NODE_ENV !== 'production' ) {
276
275
checkComponents ( child )
277
276
}
277
+
278
+ if ( typeof child === 'function' ) {
279
+ child = child . options
280
+ }
281
+
278
282
normalizeProps ( child )
279
283
normalizeDirectives ( child )
280
284
const extendsFrom = child . extends
281
285
if ( extendsFrom ) {
282
- parent = typeof extendsFrom === 'function'
283
- ? mergeOptions ( parent , extendsFrom . options , vm )
284
- : mergeOptions ( parent , extendsFrom , vm )
286
+ parent = mergeOptions ( parent , extendsFrom , vm )
285
287
}
286
288
if ( child . mixins ) {
287
289
for ( let i = 0 , l = child . mixins . length ; i < l ; i ++ ) {
288
- let mixin = child . mixins [ i ]
289
- if ( mixin . prototype instanceof Vue ) {
290
- mixin = mixin . options
291
- }
292
- parent = mergeOptions ( parent , mixin , vm )
290
+ parent = mergeOptions ( parent , child . mixins [ i ] , vm )
293
291
}
294
292
}
295
293
const options = { }
Original file line number Diff line number Diff line change @@ -124,4 +124,21 @@ describe('Global API: mixin', () => {
124
124
expect ( Test . options . computed . $style ( ) ) . toBe ( 123 )
125
125
expect ( Test . options . beforeCreate ) . toEqual ( [ mixinSpy , baseSpy , spy ] )
126
126
} )
127
+
128
+ // vue-class-component#83
129
+ it ( 'should work for a constructor mixin' , ( ) => {
130
+ const spy = jasmine . createSpy ( 'global mixin' )
131
+ const Mixin = Vue . extend ( {
132
+ created ( ) {
133
+ spy ( this . $options . myOption )
134
+ }
135
+ } )
136
+
137
+ Vue . mixin ( Mixin )
138
+
139
+ new Vue ( {
140
+ myOption : 'hello'
141
+ } )
142
+ expect ( spy ) . toHaveBeenCalledWith ( 'hello' )
143
+ } )
127
144
} )
You can’t perform that action at this time.
0 commit comments