@@ -2527,13 +2527,13 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
2527
2527
2528
2528
function objectWithoutProperties ( obj , exclude ) { var target = { } ; for ( var k in obj ) if ( Object . prototype . hasOwnProperty . call ( obj , k ) && exclude . indexOf ( k ) === - 1 ) target [ k ] = obj [ k ] ; return target ; }
2529
2529
2530
- function createContext ( options , scopedSlots ) {
2530
+ function createContext ( options , scopedSlots , currentProps ) {
2531
2531
var on = Object . assign ( { } , ( options . context && options . context . on ) ,
2532
2532
options . listeners ) ;
2533
2533
return Object . assign ( { } , { attrs : Object . assign ( { } , options . attrs ,
2534
2534
// pass as attrs so that inheritAttrs works correctly
2535
- // propsData should take precedence over attrs
2536
- options . propsData ) } ,
2535
+ // props should take precedence over attrs
2536
+ currentProps ) } ,
2537
2537
( options . context || { } ) ,
2538
2538
{ on : on ,
2539
2539
scopedSlots : scopedSlots } )
@@ -2622,15 +2622,23 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
2622
2622
var originalParentComponentProvide = parentComponentOptions . provide ;
2623
2623
parentComponentOptions . provide = function ( ) {
2624
2624
return Object . assign ( { } , getValuesFromCallableOption . call ( this , originalParentComponentProvide ) ,
2625
+ // $FlowIgnore
2625
2626
getValuesFromCallableOption . call ( this , options . provide ) )
2626
2627
} ;
2627
2628
2629
+ var originalParentComponentData = parentComponentOptions . data ;
2630
+ parentComponentOptions . data = function ( ) {
2631
+ return Object . assign ( { } , getValuesFromCallableOption . call ( this , originalParentComponentData ) ,
2632
+ { vueTestUtils_childProps : Object . assign ( { } , options . propsData ) } )
2633
+ } ;
2634
+
2628
2635
parentComponentOptions . $_doNotStubChildren = true ;
2636
+ parentComponentOptions . $_isWrapperParent = true ;
2629
2637
parentComponentOptions . _isFunctionalContainer = componentOptions . functional ;
2630
2638
parentComponentOptions . render = function ( h ) {
2631
2639
return h (
2632
2640
Constructor ,
2633
- createContext ( options , scopedSlots ) ,
2641
+ createContext ( options , scopedSlots , this . vueTestUtils_childProps ) ,
2634
2642
createChildren ( this , h , options )
2635
2643
)
2636
2644
} ;
@@ -2892,13 +2900,14 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
2892
2900
vm . _error = error ;
2893
2901
}
2894
2902
2903
+ if ( ! instancedErrorHandlers . length ) {
2904
+ throw error
2905
+ }
2895
2906
// should be one error handler, as only once can be registered with local vue
2896
2907
// regardless, if more exist (for whatever reason), invoke the other user defined error handlers
2897
2908
instancedErrorHandlers . forEach ( function ( instancedErrorHandler ) {
2898
2909
instancedErrorHandler ( error , vm , info ) ;
2899
2910
} ) ;
2900
-
2901
- throw error
2902
2911
}
2903
2912
2904
2913
function throwIfInstancesThrew ( vm ) {
@@ -3022,7 +3031,6 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
3022
3031
mocks : { } ,
3023
3032
methods : { } ,
3024
3033
provide : { } ,
3025
- silent : true ,
3026
3034
showDeprecationWarnings :
3027
3035
true
3028
3036
} ;
@@ -11037,71 +11045,49 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
11037
11045
if ( ! this . vm ) {
11038
11046
throwError ( "wrapper.setProps() can only be called on a Vue instance" ) ;
11039
11047
}
11040
- this . __warnIfDestroyed ( ) ;
11041
-
11042
- // Save the original "silent" config so that we can directly mutate props
11043
- var originalConfig = Vue__default [ 'default' ] . config . silent ;
11044
- Vue__default [ 'default' ] . config . silent = config . silent ;
11045
11048
11046
- try {
11047
- Object . keys ( data ) . forEach ( function ( key ) {
11048
- // Don't let people set entire objects, because reactivity won't work
11049
- if (
11050
- typeof data [ key ] === 'object' &&
11051
- data [ key ] !== null &&
11052
- // $FlowIgnore : Problem with possibly null this.vm
11053
- data [ key ] === this$1 . vm [ key ]
11054
- ) {
11055
- throwError (
11056
- "wrapper.setProps() called with the same object of the existing " +
11057
- key + " property. You must call wrapper.setProps() with a new " +
11058
- "object to trigger reactivity"
11059
- ) ;
11060
- }
11049
+ // $FlowIgnore : Problem with possibly null this.vm
11050
+ if ( ! this . vm . $parent . $options . $_isWrapperParent ) {
11051
+ throwError (
11052
+ "wrapper.setProps() can only be called for top-level component"
11053
+ ) ;
11054
+ }
11061
11055
11062
- if (
11063
- ! this$1 . vm ||
11064
- ! this$1 . vm . $options . _propKeys ||
11065
- ! this$1 . vm . $options . _propKeys . some ( function ( prop ) { return prop === key ; } )
11066
- ) {
11067
- if ( VUE_VERSION > 2.3 ) {
11068
- // $FlowIgnore : Problem with possibly null this.vm
11069
- this$1 . vm . $attrs [ key ] = data [ key ] ;
11070
- return nextTick ( )
11071
- }
11072
- throwError (
11073
- "wrapper.setProps() called with " + key + " property which " +
11074
- "is not defined on the component"
11075
- ) ;
11076
- }
11056
+ this . __warnIfDestroyed ( ) ;
11077
11057
11078
- // Actually set the prop
11058
+ Object . keys ( data ) . forEach ( function ( key ) {
11059
+ // Don't let people set entire objects, because reactivity won't work
11060
+ if (
11061
+ typeof data [ key ] === 'object' &&
11062
+ data [ key ] !== null &&
11079
11063
// $FlowIgnore : Problem with possibly null this.vm
11080
- this$1 . vm [ key ] = data [ key ] ;
11081
- } ) ;
11064
+ data [ key ] === this$1 . vm [ key ]
11065
+ ) {
11066
+ throwError (
11067
+ "wrapper.setProps() called with the same object of the existing " +
11068
+ key + " property. You must call wrapper.setProps() with a new " +
11069
+ "object to trigger reactivity"
11070
+ ) ;
11071
+ }
11072
+
11073
+ if (
11074
+ VUE_VERSION <= 2.3 &&
11075
+ ( ! this$1 . vm ||
11076
+ ! this$1 . vm . $options . _propKeys ||
11077
+ ! this$1 . vm . $options . _propKeys . some ( function ( prop ) { return prop === key ; } ) )
11078
+ ) {
11079
+ throwError (
11080
+ "wrapper.setProps() called with " + key + " property which " +
11081
+ "is not defined on the component"
11082
+ ) ;
11083
+ }
11082
11084
11083
11085
// $FlowIgnore : Problem with possibly null this.vm
11084
- this . vm . $forceUpdate ( ) ;
11085
- return new Promise ( function ( resolve ) {
11086
- nextTick ( ) . then ( function ( ) {
11087
- var isUpdated = Object . keys ( data ) . some ( function ( key ) {
11088
- return (
11089
- // $FlowIgnore : Problem with possibly null this.vm
11090
- this$1 . vm [ key ] === data [ key ] ||
11091
- // $FlowIgnore : Problem with possibly null this.vm
11092
- ( this$1 . vm . $attrs && this$1 . vm . $attrs [ key ] === data [ key ] )
11093
- )
11094
- } ) ;
11095
- return ! isUpdated ? this$1 . setProps ( data ) . then ( resolve ( ) ) : resolve ( )
11096
- } ) ;
11097
- } )
11098
- } catch ( err ) {
11099
- throw err
11100
- } finally {
11101
- // Ensure you teardown the modifications you made to the user's config
11102
- // After all the props are set, then reset the state
11103
- Vue__default [ 'default' ] . config . silent = originalConfig ;
11104
- }
11086
+ var parent = this$1 . vm . $parent ;
11087
+ parent . $set ( parent . vueTestUtils_childProps , key , data [ key ] ) ;
11088
+ } ) ;
11089
+
11090
+ return nextTick ( )
11105
11091
} ;
11106
11092
11107
11093
/**
0 commit comments