@@ -18,9 +18,10 @@ export function initExtend (Vue: GlobalAPI) {
1818 Vue . extend = function ( extendOptions : Object ) : Function {
1919 extendOptions = extendOptions || { }
2020 const Super = this
21- const isFirstExtend = Super . cid === 0
22- if ( isFirstExtend && extendOptions . _Ctor ) {
23- return extendOptions . _Ctor
21+ const SuperId = Super . cid
22+ const cachedCtors = extendOptions . _Ctor || ( extendOptions . _Ctor = { } )
23+ if ( cachedCtors [ SuperId ] ) {
24+ return cachedCtors [ SuperId ]
2425 }
2526 const name = extendOptions . name || Super . options . name
2627 if ( process . env . NODE_ENV !== 'production' ) {
@@ -42,8 +43,10 @@ export function initExtend (Vue: GlobalAPI) {
4243 extendOptions
4344 )
4445 Sub [ 'super' ] = Super
45- // allow further extension
46+ // allow further extension/mixin/plugin usage
4647 Sub . extend = Super . extend
48+ Sub . mixin = Super . mixin
49+ Sub . use = Super . use
4750 // create asset registers, so extended classes
4851 // can have their private assets too.
4952 config . _assetTypes . forEach ( function ( type ) {
@@ -59,9 +62,7 @@ export function initExtend (Vue: GlobalAPI) {
5962 Sub . superOptions = Super . options
6063 Sub . extendOptions = extendOptions
6164 // cache constructor
62- if ( isFirstExtend ) {
63- extendOptions . _Ctor = Sub
64- }
65+ cachedCtors [ SuperId ] = Sub
6566 return Sub
6667 }
6768}
0 commit comments