File tree 2 files changed +33
-7
lines changed
test/unit/features/global-api
2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -378,15 +378,22 @@ export function mergeOptions (
378
378
normalizeProps ( child , vm )
379
379
normalizeInject ( child , vm )
380
380
normalizeDirectives ( child )
381
- const extendsFrom = child . extends
382
- if ( extendsFrom ) {
383
- parent = mergeOptions ( parent , extendsFrom , vm )
384
- }
385
- if ( child . mixins ) {
386
- for ( let i = 0 , l = child . mixins . length ; i < l ; i ++ ) {
387
- parent = mergeOptions ( parent , child . mixins [ i ] , vm )
381
+
382
+ // Apply extends and mixins on the child options,
383
+ // but only if it is a raw options object that isn't
384
+ // the result of another mergeOptions call.
385
+ // Only merged options has the _base property.
386
+ if ( ! child . _base ) {
387
+ if ( child . extends ) {
388
+ parent = mergeOptions ( parent , child . extends , vm )
389
+ }
390
+ if ( child . mixins ) {
391
+ for ( let i = 0 , l = child . mixins . length ; i < l ; i ++ ) {
392
+ parent = mergeOptions ( parent , child . mixins [ i ] , vm )
393
+ }
388
394
}
389
395
}
396
+
390
397
const options = { }
391
398
let key
392
399
for ( key in parent ) {
Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ describe('Global API: extend', () => {
71
71
expect ( calls ) . toEqual ( [ 1 , 2 , 3 ] )
72
72
} )
73
73
74
+ it ( 'should not merge nested mixins created with Vue.extend' , ( ) => {
75
+ const A = Vue . extend ( {
76
+ created : ( ) => { }
77
+ } )
78
+ const B = Vue . extend ( {
79
+ mixins : [ A ] ,
80
+ created : ( ) => { }
81
+ } )
82
+ const C = Vue . extend ( {
83
+ extends : B ,
84
+ created : ( ) => { }
85
+ } )
86
+ const D = Vue . extend ( {
87
+ mixins : [ C ] ,
88
+ created : ( ) => { }
89
+ } )
90
+ expect ( D . options . created . length ) . toBe ( 4 )
91
+ } )
92
+
74
93
it ( 'should merge methods' , ( ) => {
75
94
const A = Vue . extend ( {
76
95
methods : {
You can’t perform that action at this time.
0 commit comments