@@ -430,6 +430,7 @@ export function applyOptions(
430
430
options : ComponentOptions ,
431
431
deferredData : DataFn [ ] = [ ] ,
432
432
deferredWatch : ComponentWatchOptions [ ] = [ ] ,
433
+ deferredProvide : ( Data | Function ) [ ] = [ ] ,
433
434
asMixin : boolean = false
434
435
) {
435
436
const {
@@ -483,16 +484,29 @@ export function applyOptions(
483
484
)
484
485
isInBeforeCreate = false
485
486
// global mixins are applied first
486
- applyMixins ( instance , globalMixins , deferredData , deferredWatch )
487
+ applyMixins (
488
+ instance ,
489
+ globalMixins ,
490
+ deferredData ,
491
+ deferredWatch ,
492
+ deferredProvide
493
+ )
487
494
}
488
495
489
496
// extending a base component...
490
497
if ( extendsOptions ) {
491
- applyOptions ( instance , extendsOptions , deferredData , deferredWatch , true )
498
+ applyOptions (
499
+ instance ,
500
+ extendsOptions ,
501
+ deferredData ,
502
+ deferredWatch ,
503
+ deferredProvide ,
504
+ true
505
+ )
492
506
}
493
507
// local mixins
494
508
if ( mixins ) {
495
- applyMixins ( instance , mixins , deferredData , deferredWatch )
509
+ applyMixins ( instance , mixins , deferredData , deferredWatch , deferredProvide )
496
510
}
497
511
498
512
const checkDuplicateProperties = __DEV__ ? createDuplicateChecker ( ) : null
@@ -634,12 +648,17 @@ export function applyOptions(
634
648
}
635
649
636
650
if ( provideOptions ) {
637
- const provides = isFunction ( provideOptions )
638
- ? provideOptions . call ( publicThis )
639
- : provideOptions
640
- for ( const key in provides ) {
641
- provide ( key , provides [ key ] )
642
- }
651
+ deferredProvide . push ( provideOptions )
652
+ }
653
+ if ( ! asMixin && deferredProvide . length ) {
654
+ deferredProvide . forEach ( provideOptions => {
655
+ const provides = isFunction ( provideOptions )
656
+ ? provideOptions . call ( publicThis )
657
+ : provideOptions
658
+ for ( const key in provides ) {
659
+ provide ( key , provides [ key ] )
660
+ }
661
+ } )
643
662
}
644
663
645
664
// asset options.
@@ -777,10 +796,18 @@ function applyMixins(
777
796
instance : ComponentInternalInstance ,
778
797
mixins : ComponentOptions [ ] ,
779
798
deferredData : DataFn [ ] ,
780
- deferredWatch : ComponentWatchOptions [ ]
799
+ deferredWatch : ComponentWatchOptions [ ] ,
800
+ deferredProvide : ( Data | Function ) [ ]
781
801
) {
782
802
for ( let i = 0 ; i < mixins . length ; i ++ ) {
783
- applyOptions ( instance , mixins [ i ] , deferredData , deferredWatch , true )
803
+ applyOptions (
804
+ instance ,
805
+ mixins [ i ] ,
806
+ deferredData ,
807
+ deferredWatch ,
808
+ deferredProvide ,
809
+ true
810
+ )
784
811
}
785
812
}
786
813
0 commit comments