1
1
// @flow
2
-
3
- import Vue from 'vue'
4
2
import pretty from 'pretty'
5
3
import getSelector from './get-selector'
6
4
import { REF_SELECTOR , FUNCTIONAL_OPTIONS , VUE_VERSION } from 'shared/consts'
7
- import config from './config'
8
5
import WrapperArray from './wrapper-array'
9
6
import ErrorWrapper from './error-wrapper'
10
7
import { throwError , getCheckedEvent , isPhantomJS } from 'shared/util'
@@ -455,8 +452,6 @@ export default class Wrapper implements BaseWrapper {
455
452
* Sets vm props
456
453
*/
457
454
setProps ( data : Object ) : void {
458
- const originalConfig = Vue . config . silent
459
- Vue . config . silent = config . silent
460
455
if ( this . isFunctionalComponent ) {
461
456
throwError (
462
457
`wrapper.setProps() cannot be called on a functional component`
@@ -480,38 +475,26 @@ export default class Wrapper implements BaseWrapper {
480
475
)
481
476
}
482
477
if (
483
- ! this . vm ||
484
- ! this . vm . $options . _propKeys ||
485
- ! this . vm . $options . _propKeys . some ( prop => prop === key )
478
+ VUE_VERSION <= 2.3 &&
479
+ // $FlowIgnore : Problem with possibly null this.vm
480
+ ( ! this . vm . $options . _propKeys ||
481
+ ! this . vm . $options . _propKeys . some ( prop => prop === key ) )
486
482
) {
487
- if ( VUE_VERSION > 2.3 ) {
488
- // $FlowIgnore : Problem with possibly null this.vm
489
- this . vm . $attrs [ key ] = data [ key ]
490
- return
491
- }
492
483
throwError (
493
484
`wrapper.setProps() called with ${ key } property which ` +
494
485
`is not defined on the component`
495
486
)
496
487
}
497
488
498
- if ( this . vm && this . vm . _props ) {
499
- // Set actual props value
500
- this . vm . _props [ key ] = data [ key ]
501
- // $FlowIgnore : Problem with possibly null this.vm
502
- this . vm [ key ] = data [ key ]
503
- } else {
504
- // $FlowIgnore : Problem with possibly null this.vm.$options
505
- this . vm . $options . propsData [ key ] = data [ key ]
506
- // $FlowIgnore : Problem with possibly null this.vm
507
- this . vm [ key ] = data [ key ]
508
- // $FlowIgnore : Need to call this twice to fix watcher bug in 2.0.x
509
- this . vm [ key ] = data [ key ]
489
+ if ( this . vm && this . vm . $parent ) {
490
+ this . vm . $parent . vueTestUtils_childProps [ key ] = data [ key ]
510
491
}
511
492
} )
512
493
// $FlowIgnore : Problem with possibly null this.vm
513
494
this . vm . $forceUpdate ( )
514
- Vue . config . silent = originalConfig
495
+ // We need to explicitly trigger parent watcher to support sync scenarios
496
+ // $FlowIgnore : Problem with possibly null this.vm
497
+ this . vm . $parent . _watcher . run ( )
515
498
}
516
499
517
500
/**
0 commit comments