@@ -8116,7 +8116,11 @@ function recursivelySetData(vm, target, data) {
8116
8116
var val = data [ key ] ;
8117
8117
var targetVal = target [ key ] ;
8118
8118
8119
- if ( isPlainObject ( val ) && isPlainObject ( targetVal ) ) {
8119
+ if (
8120
+ isPlainObject ( val ) &&
8121
+ isPlainObject ( targetVal ) &&
8122
+ Object . keys ( val ) . length > 0
8123
+ ) {
8120
8124
recursivelySetData ( vm , targetVal , val ) ;
8121
8125
} else {
8122
8126
vm . $set ( target , key , val ) ;
@@ -9481,14 +9485,27 @@ var Wrapper = function Wrapper(
9481
9485
}
9482
9486
} ;
9483
9487
9488
+ /**
9489
+ * Prints warning if component is destroyed
9490
+ */
9491
+ Wrapper . prototype . __warnIfDestroyed = function __warnIfDestroyed ( ) {
9492
+ if ( ! this . exists ( ) ) {
9493
+ warn ( 'Operations on destroyed component are discouraged' ) ;
9494
+ }
9495
+ } ;
9496
+
9484
9497
Wrapper . prototype . at = function at ( ) {
9498
+ this . __warnIfDestroyed ( ) ;
9499
+
9485
9500
throwError ( 'at() must be called on a WrapperArray' ) ;
9486
9501
} ;
9487
9502
9488
9503
/**
9489
9504
* Returns an Object containing all the attribute/value pairs on the element.
9490
9505
*/
9491
9506
Wrapper . prototype . attributes = function attributes ( key ) {
9507
+ this . __warnIfDestroyed ( ) ;
9508
+
9492
9509
var attributes = this . element . attributes ;
9493
9510
var attributeMap = { } ;
9494
9511
for ( var i = 0 ; i < attributes . length ; i ++ ) {
@@ -9505,6 +9522,8 @@ Wrapper.prototype.attributes = function attributes (key) {
9505
9522
Wrapper . prototype . classes = function classes ( className ) {
9506
9523
var this$1 = this ;
9507
9524
9525
+ this . __warnIfDestroyed ( ) ;
9526
+
9508
9527
var classAttribute = this . element . getAttribute ( 'class' ) ;
9509
9528
var classes = classAttribute ? classAttribute . split ( ' ' ) : [ ] ;
9510
9529
// Handle converting cssmodules identifiers back to the original class name
@@ -9535,6 +9554,9 @@ Wrapper.prototype.contains = function contains (rawSelector) {
9535
9554
'contains' ,
9536
9555
'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
9537
9556
) ;
9557
+
9558
+ this . __warnIfDestroyed ( ) ;
9559
+
9538
9560
var selector = getSelector ( rawSelector , 'contains' ) ;
9539
9561
var nodes = find ( this . rootNode , this . vm , selector ) ;
9540
9562
return nodes . length > 0
@@ -9610,23 +9632,41 @@ Wrapper.prototype.filter = function filter () {
9610
9632
* matches the provided selector.
9611
9633
*/
9612
9634
Wrapper . prototype . get = function get ( rawSelector ) {
9635
+ this . __warnIfDestroyed ( ) ;
9636
+
9613
9637
var found = this . find ( rawSelector ) ;
9614
9638
if ( found instanceof ErrorWrapper ) {
9615
9639
throw new Error ( ( "Unable to find " + rawSelector + " within: " + ( this . html ( ) ) ) )
9616
9640
}
9617
9641
return found
9618
9642
} ;
9619
9643
9644
+ /**
9645
+ * Gets first node in tree of the current wrapper that
9646
+ * matches the provided selector.
9647
+ */
9648
+ Wrapper . prototype . getComponent = function getComponent ( rawSelector ) {
9649
+ this . __warnIfDestroyed ( ) ;
9650
+
9651
+ var found = this . findComponent ( rawSelector ) ;
9652
+ if ( found instanceof ErrorWrapper ) {
9653
+ throw new Error ( ( "Unable to get " + rawSelector + " within: " + ( this . html ( ) ) ) )
9654
+ }
9655
+ return found
9656
+ } ;
9657
+
9620
9658
/**
9621
9659
* Finds first DOM node in tree of the current wrapper that
9622
9660
* matches the provided selector.
9623
9661
*/
9624
9662
Wrapper . prototype . find = function find ( rawSelector ) {
9663
+ this . __warnIfDestroyed ( ) ;
9664
+
9625
9665
var selector = getSelector ( rawSelector , 'find' ) ;
9626
9666
if ( selector . type !== DOM_SELECTOR ) {
9627
9667
warnDeprecated (
9628
- 'finding components with `find`' ,
9629
- 'Use `findComponent` instead'
9668
+ 'finding components with `find` or `get` ' ,
9669
+ 'Use `findComponent` and `getComponent` instead'
9630
9670
) ;
9631
9671
}
9632
9672
@@ -9638,6 +9678,8 @@ Wrapper.prototype.find = function find (rawSelector) {
9638
9678
* matches the provided selector.
9639
9679
*/
9640
9680
Wrapper . prototype . findComponent = function findComponent ( rawSelector ) {
9681
+ this . __warnIfDestroyed ( ) ;
9682
+
9641
9683
var selector = getSelector ( rawSelector , 'findComponent' ) ;
9642
9684
if ( ! this . vm && ! this . isFunctionalComponent ) {
9643
9685
throwError (
@@ -9671,6 +9713,8 @@ Wrapper.prototype.__find = function __find (rawSelector, selector) {
9671
9713
* the provided selector.
9672
9714
*/
9673
9715
Wrapper . prototype . findAll = function findAll ( rawSelector ) {
9716
+ this . __warnIfDestroyed ( ) ;
9717
+
9674
9718
var selector = getSelector ( rawSelector , 'findAll' ) ;
9675
9719
if ( selector . type !== DOM_SELECTOR ) {
9676
9720
warnDeprecated (
@@ -9686,6 +9730,8 @@ Wrapper.prototype.findAll = function findAll (rawSelector) {
9686
9730
* the provided selector.
9687
9731
*/
9688
9732
Wrapper . prototype . findAllComponents = function findAllComponents ( rawSelector ) {
9733
+ this . __warnIfDestroyed ( ) ;
9734
+
9689
9735
var selector = getSelector ( rawSelector , 'findAll' ) ;
9690
9736
if ( ! this . vm ) {
9691
9737
throwError (
@@ -9721,13 +9767,17 @@ Wrapper.prototype.__findAll = function __findAll (rawSelector, selector) {
9721
9767
* Returns HTML of element as a string
9722
9768
*/
9723
9769
Wrapper . prototype . html = function html ( ) {
9770
+ this . __warnIfDestroyed ( ) ;
9771
+
9724
9772
return pretty ( this . element . outerHTML )
9725
9773
} ;
9726
9774
9727
9775
/**
9728
9776
* Checks if node matches selector or component definition
9729
9777
*/
9730
9778
Wrapper . prototype . is = function is ( rawSelector ) {
9779
+ this . __warnIfDestroyed ( ) ;
9780
+
9731
9781
var selector = getSelector ( rawSelector , 'is' ) ;
9732
9782
9733
9783
if ( selector . type === DOM_SELECTOR ) {
@@ -9754,6 +9804,8 @@ Wrapper.prototype.isEmpty = function isEmpty () {
9754
9804
'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
9755
9805
'When using with findComponent, access the DOM element with findComponent(Comp).element'
9756
9806
) ;
9807
+ this . __warnIfDestroyed ( ) ;
9808
+
9757
9809
if ( ! this . vnode ) {
9758
9810
return this . element . innerHTML === ''
9759
9811
}
@@ -9778,6 +9830,8 @@ Wrapper.prototype.isEmpty = function isEmpty () {
9778
9830
* Checks if node is visible
9779
9831
*/
9780
9832
Wrapper . prototype . isVisible = function isVisible ( ) {
9833
+ this . __warnIfDestroyed ( ) ;
9834
+
9781
9835
return isElementVisible ( this . element )
9782
9836
} ;
9783
9837
@@ -9787,6 +9841,8 @@ Wrapper.prototype.isVisible = function isVisible () {
9787
9841
*/
9788
9842
Wrapper . prototype . isVueInstance = function isVueInstance ( ) {
9789
9843
warnDeprecated ( "isVueInstance" ) ;
9844
+ this . __warnIfDestroyed ( ) ;
9845
+
9790
9846
return ! ! this . vm
9791
9847
} ;
9792
9848
@@ -9796,6 +9852,7 @@ Wrapper.prototype.isVueInstance = function isVueInstance () {
9796
9852
*/
9797
9853
Wrapper . prototype . name = function name ( ) {
9798
9854
warnDeprecated ( "name" ) ;
9855
+ this . __warnIfDestroyed ( ) ;
9799
9856
9800
9857
if ( this . vm ) {
9801
9858
return (
@@ -9821,6 +9878,7 @@ Wrapper.prototype.overview = function overview () {
9821
9878
var this$1 = this ;
9822
9879
9823
9880
warnDeprecated ( "overview" ) ;
9881
+ this . __warnIfDestroyed ( ) ;
9824
9882
9825
9883
if ( ! this . vm ) {
9826
9884
throwError ( "wrapper.overview() can only be called on a Vue instance" ) ;
@@ -9907,6 +9965,7 @@ Wrapper.prototype.props = function props (key) {
9907
9965
if ( ! this . vm ) {
9908
9966
throwError ( 'wrapper.props() must be called on a Vue instance' ) ;
9909
9967
}
9968
+ this . __warnIfDestroyed ( ) ;
9910
9969
9911
9970
var props = { } ;
9912
9971
var keys = this . vm && this . vm . $options . _propKeys ;
@@ -9933,6 +9992,8 @@ Wrapper.prototype.props = function props (key) {
9933
9992
Wrapper . prototype . setChecked = function setChecked ( checked ) {
9934
9993
if ( checked === void 0 ) checked = true ;
9935
9994
9995
+ this . __warnIfDestroyed ( ) ;
9996
+
9936
9997
if ( typeof checked !== 'boolean' ) {
9937
9998
throwError ( 'wrapper.setChecked() must be passed a boolean' ) ;
9938
9999
}
@@ -9982,6 +10043,8 @@ Wrapper.prototype.setChecked = function setChecked (checked) {
9982
10043
* @deprecated
9983
10044
*/
9984
10045
Wrapper . prototype . setSelected = function setSelected ( ) {
10046
+ this . __warnIfDestroyed ( ) ;
10047
+
9985
10048
var tagName = this . element . tagName ;
9986
10049
9987
10050
if ( tagName === 'SELECT' ) {
@@ -10027,6 +10090,8 @@ Wrapper.prototype.setData = function setData (data) {
10027
10090
throwError ( "wrapper.setData() can only be called on a Vue instance" ) ;
10028
10091
}
10029
10092
10093
+ this . __warnIfDestroyed ( ) ;
10094
+
10030
10095
recursivelySetData ( this . vm , this . vm , data ) ;
10031
10096
return nextTick ( )
10032
10097
} ;
@@ -10046,6 +10111,8 @@ Wrapper.prototype.setMethods = function setMethods (methods) {
10046
10111
if ( ! this . vm ) {
10047
10112
throwError ( "wrapper.setMethods() can only be called on a Vue instance" ) ;
10048
10113
}
10114
+ this . __warnIfDestroyed ( ) ;
10115
+
10049
10116
Object . keys ( methods ) . forEach ( function ( key ) {
10050
10117
// $FlowIgnore : Problem with possibly null this.vm
10051
10118
this$1 . vm [ key ] = methods [ key ] ;
@@ -10075,6 +10142,7 @@ Wrapper.prototype.setProps = function setProps (data) {
10075
10142
if ( ! this . vm ) {
10076
10143
throwError ( "wrapper.setProps() can only be called on a Vue instance" ) ;
10077
10144
}
10145
+ this . __warnIfDestroyed ( ) ;
10078
10146
10079
10147
// Save the original "silent" config so that we can directly mutate props
10080
10148
var originalConfig = Vue__default [ 'default' ] . config . silent ;
@@ -10148,6 +10216,7 @@ Wrapper.prototype.setValue = function setValue (value) {
10148
10216
var tagName = this . element . tagName ;
10149
10217
// $FlowIgnore
10150
10218
var type = this . attributes ( ) . type ;
10219
+ this . __warnIfDestroyed ( ) ;
10151
10220
10152
10221
if ( tagName === 'OPTION' ) {
10153
10222
throwError (
@@ -10200,6 +10269,8 @@ Wrapper.prototype.setValue = function setValue (value) {
10200
10269
* Return text of wrapper element
10201
10270
*/
10202
10271
Wrapper . prototype . text = function text ( ) {
10272
+ this . __warnIfDestroyed ( ) ;
10273
+
10203
10274
return this . element . textContent . trim ( )
10204
10275
} ;
10205
10276
@@ -10209,6 +10280,8 @@ Wrapper.prototype.text = function text () {
10209
10280
Wrapper . prototype . trigger = function trigger ( type , options ) {
10210
10281
if ( options === void 0 ) options = { } ;
10211
10282
10283
+ this . __warnIfDestroyed ( ) ;
10284
+
10212
10285
if ( typeof type !== 'string' ) {
10213
10286
throwError ( 'wrapper.trigger() must be passed a string' ) ;
10214
10287
}
@@ -13112,7 +13185,11 @@ function warnDeprecated(method, fallback) {
13112
13185
if ( ! config . showDeprecationWarnings ) { return }
13113
13186
var msg = method + " is deprecated and will be removed in the next major version." ;
13114
13187
if ( fallback ) { msg += " " + fallback + "." ; }
13115
- warn ( msg ) ;
13188
+ if ( config . deprecationWarningHandler ) {
13189
+ config . deprecationWarningHandler ( method , msg ) ;
13190
+ } else {
13191
+ warn ( msg ) ;
13192
+ }
13116
13193
}
13117
13194
13118
13195
//
@@ -13372,7 +13449,8 @@ function getCoreProperties(componentOptions) {
13372
13449
style : componentOptions . style ,
13373
13450
normalizedStyle : componentOptions . normalizedStyle ,
13374
13451
nativeOn : componentOptions . nativeOn ,
13375
- functional : componentOptions . functional
13452
+ functional : componentOptions . functional ,
13453
+ abstract : componentOptions . abstract
13376
13454
}
13377
13455
}
13378
13456
@@ -13452,6 +13530,9 @@ function createStubFromComponent(
13452
13530
tagName ,
13453
13531
{
13454
13532
ref : componentOptions . functional ? context . data . ref : undefined ,
13533
+ domProps : componentOptions . functional
13534
+ ? context . data . domProps
13535
+ : undefined ,
13455
13536
attrs : componentOptions . functional
13456
13537
? Object . assign ( { } , context . props ,
13457
13538
context . data . attrs ,
0 commit comments