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'
@@ -478,8 +475,6 @@ export default class Wrapper implements BaseWrapper {
478
475
* Sets vm props
479
476
*/
480
477
setProps ( data : Object ) : void {
481
- const originalConfig = Vue . config . silent
482
- Vue . config . silent = config . silent
483
478
if ( this . isFunctionalComponent ) {
484
479
throwError (
485
480
`wrapper.setProps() cannot be called on a functional component`
@@ -503,38 +498,26 @@ export default class Wrapper implements BaseWrapper {
503
498
)
504
499
}
505
500
if (
506
- ! this . vm ||
507
- ! this . vm . $options . _propKeys ||
508
- ! this . vm . $options . _propKeys . some ( prop => prop === key )
501
+ VUE_VERSION <= 2.3 &&
502
+ // $FlowIgnore : Problem with possibly null this.vm
503
+ ( ! this . vm . $options . _propKeys ||
504
+ ! this . vm . $options . _propKeys . some ( prop => prop === key ) )
509
505
) {
510
- if ( VUE_VERSION > 2.3 ) {
511
- // $FlowIgnore : Problem with possibly null this.vm
512
- this . vm . $attrs [ key ] = data [ key ]
513
- return
514
- }
515
506
throwError (
516
507
`wrapper.setProps() called with ${ key } property which ` +
517
508
`is not defined on the component`
518
509
)
519
510
}
520
511
521
- if ( this . vm && this . vm . _props ) {
522
- // Set actual props value
523
- this . vm . _props [ key ] = data [ key ]
524
- // $FlowIgnore : Problem with possibly null this.vm
525
- this . vm [ key ] = data [ key ]
526
- } else {
527
- // $FlowIgnore : Problem with possibly null this.vm.$options
528
- this . vm . $options . propsData [ key ] = data [ key ]
529
- // $FlowIgnore : Problem with possibly null this.vm
530
- this . vm [ key ] = data [ key ]
531
- // $FlowIgnore : Need to call this twice to fix watcher bug in 2.0.x
532
- this . vm [ key ] = data [ key ]
512
+ if ( this . vm && this . vm . $parent ) {
513
+ this . vm . $parent . vueTestUtils_childProps [ key ] = data [ key ]
533
514
}
534
515
} )
535
516
// $FlowIgnore : Problem with possibly null this.vm
536
517
this . vm . $forceUpdate ( )
537
- Vue . config . silent = originalConfig
518
+ // We need to explicitly trigger parent watcher to support sync scenarios
519
+ // $FlowIgnore : Problem with possibly null this.vm
520
+ this . vm . $parent . _watcher . run ( )
538
521
}
539
522
540
523
/**
0 commit comments