File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed
test/unit/features/global-api Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -378,15 +378,22 @@ export function mergeOptions (
378378 normalizeProps ( child , vm )
379379 normalizeInject ( child , vm )
380380 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+ }
388394 }
389395 }
396+
390397 const options = { }
391398 let key
392399 for ( key in parent ) {
Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ describe('Global API: extend', () => {
7171 expect ( calls ) . toEqual ( [ 1 , 2 , 3 ] )
7272 } )
7373
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+
7493 it ( 'should merge methods' , ( ) => {
7594 const A = Vue . extend ( {
7695 methods : {
You can’t perform that action at this time.
0 commit comments