@@ -816,59 +816,31 @@ function callSyncHook(
816
816
instance : ComponentInternalInstance ,
817
817
globalMixins : ComponentOptions [ ]
818
818
) {
819
- callHookFromMixins ( name , type , globalMixins , instance )
820
- const { extends : base , mixins } = options
821
- if ( base ) {
822
- callHookFromExtends ( name , type , base , instance )
823
- }
824
- if ( mixins ) {
825
- callHookFromMixins ( name , type , mixins , instance )
826
- }
827
- const selfHook = options [ name ]
828
- if ( selfHook ) {
829
- callWithAsyncErrorHandling ( selfHook . bind ( instance . proxy ! ) , instance , type )
819
+ for ( let i = 0 ; i < globalMixins . length ; i ++ ) {
820
+ callHookWithMixinAndExtends ( name , type , globalMixins [ i ] , instance )
830
821
}
822
+ callHookWithMixinAndExtends ( name , type , options , instance )
831
823
}
832
824
833
- function callHookFromExtends (
825
+ function callHookWithMixinAndExtends (
834
826
name : 'beforeCreate' | 'created' ,
835
827
type : LifecycleHooks ,
836
- base : ComponentOptions ,
828
+ options : ComponentOptions ,
837
829
instance : ComponentInternalInstance
838
830
) {
839
- if ( base . extends ) {
840
- callHookFromExtends ( name , type , base . extends , instance )
841
- }
842
- const chainedMixins = base . mixins
843
- if ( chainedMixins ) {
844
- callHookFromMixins ( name , type , chainedMixins , instance )
845
- }
846
- const baseHook = base [ name ]
847
- if ( baseHook ) {
848
- callWithAsyncErrorHandling ( baseHook . bind ( instance . proxy ! ) , instance , type )
831
+ const { extends : base , mixins } = options
832
+ const selfHook = options [ name ]
833
+ if ( base ) {
834
+ callHookWithMixinAndExtends ( name , type , base , instance )
849
835
}
850
- }
851
-
852
- function callHookFromMixins (
853
- name : 'beforeCreate' | 'created' ,
854
- type : LifecycleHooks ,
855
- mixins : ComponentOptions [ ] ,
856
- instance : ComponentInternalInstance
857
- ) {
858
- for ( let i = 0 ; i < mixins . length ; i ++ ) {
859
- const chainedMixins = mixins [ i ] . mixins
860
- const chainedExtends = mixins [ i ] . extends
861
- if ( chainedExtends ) {
862
- callHookFromExtends ( name , type , chainedExtends , instance )
863
- }
864
- if ( chainedMixins ) {
865
- callHookFromMixins ( name , type , chainedMixins , instance )
866
- }
867
- const fn = mixins [ i ] [ name ]
868
- if ( fn ) {
869
- callWithAsyncErrorHandling ( fn . bind ( instance . proxy ! ) , instance , type )
836
+ if ( mixins ) {
837
+ for ( let i = 0 ; i < mixins . length ; i ++ ) {
838
+ callHookWithMixinAndExtends ( name , type , mixins [ i ] , instance )
870
839
}
871
840
}
841
+ if ( selfHook ) {
842
+ callWithAsyncErrorHandling ( selfHook . bind ( instance . proxy ! ) , instance , type )
843
+ }
872
844
}
873
845
874
846
function applyMixins (
0 commit comments