@@ -398,15 +398,18 @@ export default class Wrapper implements BaseWrapper {
398398 if ( ! this . vm ) {
399399 throwError ( 'wrapper.props() must be called on a Vue instance' )
400400 }
401- // $props object does not exist in Vue 2.1.x, so use $options.propsData instead
402- let _props
403- if ( this . vm && this . vm . $options && this . vm . $options . propsData ) {
404- _props = this . vm . $options . propsData
405- } else {
406- // $FlowIgnore
407- _props = this . vm . $props
401+
402+ const props = { }
403+ // $FlowIgnore
404+ const keys = this . vm . $options . _propKeys
405+
406+ if ( keys ) {
407+ keys . forEach ( key => {
408+ // $FlowIgnore
409+ props [ key ] = this . vm [ key ]
410+ } )
408411 }
409- return _props || { } // Return an empty object if no props exist
412+ return props
410413 }
411414
412415 /**
@@ -518,26 +521,21 @@ export default class Wrapper implements BaseWrapper {
518521 if ( this . isFunctionalComponent ) {
519522 throwError ( 'wrapper.setProps() cannot be called on a functional component' )
520523 }
521- if ( ! this . isVueInstance ( ) || ! this . vm ) {
524+ if ( ! this . isVm ) {
522525 throwError ( 'wrapper.setProps() can only be called on a Vue instance' )
523526 }
524- if ( this . vm && this . vm . $options && ! this . vm . $options . propsData ) {
525- this . vm . $options . propsData = { }
526- }
527+
527528 Object . keys ( data ) . forEach ( ( key ) => {
528529 // Ignore properties that were not specified in the component options
529530 // $FlowIgnore : Problem with possibly null this.vm
530- if ( ! this . vm . $options . _propKeys || ! this . vm . $options . _propKeys . some ( prop => prop === key ) ) {
531+ if ( ! this . vm . $options . _propKeys ||
532+ ! this . vm . $options . _propKeys . some ( prop => prop === key ) ) {
531533 throwError ( `wrapper.setProps() called with ${ key } property which is not defined on component` )
532534 }
533535
534536 // $FlowIgnore : Problem with possibly null this.vm
535537 if ( this . vm . _props ) {
536538 this . vm . _props [ key ] = data [ key ]
537- // $FlowIgnore : Problem with possibly null this.vm.$props
538- this . vm . $props [ key ] = data [ key ]
539- // $FlowIgnore : Problem with possibly null this.vm.$options
540- this . vm . $options . propsData [ key ] = data [ key ]
541539 } else {
542540 // $FlowIgnore : Problem with possibly null this.vm
543541 this . vm [ key ] = data [ key ]
0 commit comments