@@ -24,7 +24,7 @@ export function initMixin (Vue: Class<Component>) {
2424 initInternalComponent ( vm , options )
2525 } else {
2626 vm . $options = mergeOptions (
27- vm . constructor . options ,
27+ resolveConstructorOptions ( vm ) ,
2828 options || { } ,
2929 vm
3030 )
@@ -44,19 +44,37 @@ export function initMixin (Vue: Class<Component>) {
4444 callHook ( vm , 'created' )
4545 initRender ( vm )
4646 }
47- }
4847
49- function initInternalComponent ( vm : Component , options : InternalComponentOptions ) {
50- const opts = vm . $options = Object . create ( vm . constructor . options )
51- // doing this because it's faster than dynamic enumeration.
52- opts . parent = options . parent
53- opts . propsData = options . propsData
54- opts . _parentVnode = options . _parentVnode
55- opts . _parentListeners = options . _parentListeners
56- opts . _renderChildren = options . _renderChildren
57- opts . _componentTag = options . _componentTag
58- if ( options . render ) {
59- opts . render = options . render
60- opts . staticRenderFns = options . staticRenderFns
48+ function initInternalComponent ( vm : Component , options : InternalComponentOptions ) {
49+ const opts = vm . $options = Object . create ( resolveConstructorOptions ( vm ) )
50+ // doing this because it's faster than dynamic enumeration.
51+ opts . parent = options . parent
52+ opts . propsData = options . propsData
53+ opts . _parentVnode = options . _parentVnode
54+ opts . _parentListeners = options . _parentListeners
55+ opts . _renderChildren = options . _renderChildren
56+ opts . _componentTag = options . _componentTag
57+ if ( options . render ) {
58+ opts . render = options . render
59+ opts . staticRenderFns = options . staticRenderFns
60+ }
61+ }
62+
63+ function resolveConstructorOptions ( vm : Component ) {
64+ const Ctor = vm . constructor
65+ let options = Ctor . options
66+ if ( Ctor . super ) {
67+ const superOptions = Ctor . super . options
68+ const cachedSuperOptions = Ctor . superOptions
69+ if ( superOptions !== cachedSuperOptions ) {
70+ // super option changed
71+ Ctor . superOptions = superOptions
72+ options = Ctor . options = mergeOptions ( superOptions , Ctor . extendOptions )
73+ if ( options . name ) {
74+ options . components [ options . name ] = Ctor
75+ }
76+ }
77+ }
78+ return options
6179 }
6280}
0 commit comments