@@ -2770,7 +2770,7 @@ function isRefSelector (refOptionsObject) {
2770
2770
return isValid
2771
2771
}
2772
2772
2773
- //
2773
+ //
2774
2774
2775
2775
var selectorTypes = {
2776
2776
DOM_SELECTOR : 'DOM_SELECTOR' ,
@@ -2861,7 +2861,7 @@ function removeDuplicateNodes (vNodes) {
2861
2861
return uniqueNodes
2862
2862
}
2863
2863
2864
- //
2864
+ //
2865
2865
2866
2866
function nodeMatchesSelector ( node , selector ) {
2867
2867
return node . elm && node . elm . getAttribute && node . elm . matches ( selector )
@@ -2887,7 +2887,7 @@ function findVNodesByRef (vNode, refName) {
2887
2887
return removeDuplicateNodes ( mainVNodeFilteredNodes )
2888
2888
}
2889
2889
2890
- //
2890
+ //
2891
2891
2892
2892
2893
2893
@@ -2903,6 +2903,18 @@ WrapperArray.prototype.at = function at (index) {
2903
2903
return this . wrappers [ index ]
2904
2904
} ;
2905
2905
2906
+ WrapperArray . prototype . attributes = function attributes ( ) {
2907
+ this . throwErrorIfWrappersIsEmpty ( 'attributes' ) ;
2908
+
2909
+ throwError ( 'attributes must be called on a single wrapper, use at(i) to access a wrapper' ) ;
2910
+ } ;
2911
+
2912
+ WrapperArray . prototype . classes = function classes ( ) {
2913
+ this . throwErrorIfWrappersIsEmpty ( 'classes' ) ;
2914
+
2915
+ throwError ( 'classes must be called on a single wrapper, use at(i) to access a wrapper' ) ;
2916
+ } ;
2917
+
2906
2918
WrapperArray . prototype . contains = function contains ( selector ) {
2907
2919
this . throwErrorIfWrappersIsEmpty ( 'contains' ) ;
2908
2920
@@ -2990,6 +3002,12 @@ WrapperArray.prototype.name = function name () {
2990
3002
throwError ( 'name must be called on a single wrapper, use at(i) to access a wrapper' ) ;
2991
3003
} ;
2992
3004
3005
+ WrapperArray . prototype . props = function props ( ) {
3006
+ this . throwErrorIfWrappersIsEmpty ( 'props' ) ;
3007
+
3008
+ throwError ( 'props must be called on a single wrapper, use at(i) to access a wrapper' ) ;
3009
+ } ;
3010
+
2993
3011
WrapperArray . prototype . text = function text ( ) {
2994
3012
this . throwErrorIfWrappersIsEmpty ( 'text' ) ;
2995
3013
@@ -3053,6 +3071,14 @@ ErrorWrapper.prototype.at = function at () {
3053
3071
throwError ( ( "find did not return " + ( this . selector ) + ", cannot call at() on empty Wrapper" ) ) ;
3054
3072
} ;
3055
3073
3074
+ ErrorWrapper . prototype . attributes = function attributes ( ) {
3075
+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call attributes() on empty Wrapper" ) ) ;
3076
+ } ;
3077
+
3078
+ ErrorWrapper . prototype . classes = function classes ( ) {
3079
+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call classes() on empty Wrapper" ) ) ;
3080
+ } ;
3081
+
3056
3082
ErrorWrapper . prototype . contains = function contains ( ) {
3057
3083
throwError ( ( "find did not return " + ( this . selector ) + ", cannot call contains() on empty Wrapper" ) ) ;
3058
3084
} ;
@@ -3113,6 +3139,10 @@ ErrorWrapper.prototype.name = function name () {
3113
3139
throwError ( ( "find did not return " + ( this . selector ) + ", cannot call name() on empty Wrapper" ) ) ;
3114
3140
} ;
3115
3141
3142
+ ErrorWrapper . prototype . props = function props ( ) {
3143
+ throwError ( ( "find did not return " + ( this . selector ) + ", cannot call props() on empty Wrapper" ) ) ;
3144
+ } ;
3145
+
3116
3146
ErrorWrapper . prototype . text = function text ( ) {
3117
3147
throwError ( ( "find did not return " + ( this . selector ) + ", cannot call text() on empty Wrapper" ) ) ;
3118
3148
} ;
@@ -3159,6 +3189,41 @@ Wrapper.prototype.at = function at () {
3159
3189
throwError ( 'at() must be called on a WrapperArray' ) ;
3160
3190
} ;
3161
3191
3192
+ /**
3193
+ * Returns an Object containing all the attribute/value pairs on the element.
3194
+ */
3195
+ Wrapper . prototype . attributes = function attributes ( ) {
3196
+ var attributes = [ ] . concat ( this . element . attributes ) ; // NameNodeMap is not iterable
3197
+ var attributeMap = { } ;
3198
+ attributes . forEach ( function ( att ) {
3199
+ attributeMap [ att . localName ] = att . value ;
3200
+ } ) ;
3201
+ return attributeMap
3202
+ } ;
3203
+
3204
+ /**
3205
+ * Returns an Array containing all the classes on the element
3206
+ */
3207
+ Wrapper . prototype . classes = function classes ( ) {
3208
+ var this$1 = this ;
3209
+
3210
+ var classes = [ ] . concat ( this . element . classList ) ;
3211
+ // Handle converting cssmodules identifiers back to the original class name
3212
+ if ( this . vm && this . vm . $style ) {
3213
+ var cssModuleIdentifiers = { } ;
3214
+ var moduleIdent ;
3215
+ Object . keys ( this . vm . $style ) . forEach ( function ( key ) {
3216
+ // $FlowIgnore : Flow thinks vm is a property
3217
+ moduleIdent = this$1 . vm . $style [ key ] ;
3218
+ // CSS Modules may be multi-class if they extend others. Extended classes should be already present in $style.
3219
+ moduleIdent = moduleIdent . split ( ' ' ) [ 0 ] ;
3220
+ cssModuleIdentifiers [ moduleIdent ] = key ;
3221
+ } ) ;
3222
+ classes = classes . map ( function ( className ) { return cssModuleIdentifiers [ className ] || className ; } ) ;
3223
+ }
3224
+ return classes
3225
+ } ;
3226
+
3162
3227
/**
3163
3228
* Checks if wrapper contains provided selector.
3164
3229
*/
@@ -3188,10 +3253,13 @@ Wrapper.prototype.contains = function contains (selector) {
3188
3253
/**
3189
3254
* Returns an object containing custom events emitted by the Wrapper vm
3190
3255
*/
3191
- Wrapper . prototype . emitted = function emitted ( ) {
3256
+ Wrapper . prototype . emitted = function emitted ( event ) {
3192
3257
if ( ! this . _emitted && ! this . vm ) {
3193
3258
throwError ( 'wrapper.emitted() can only be called on a Vue instance' ) ;
3194
3259
}
3260
+ if ( event ) {
3261
+ return this . _emitted [ event ]
3262
+ }
3195
3263
return this . _emitted
3196
3264
} ;
3197
3265
@@ -3436,6 +3504,24 @@ Wrapper.prototype.name = function name () {
3436
3504
return this . vnode . tag
3437
3505
} ;
3438
3506
3507
+ /**
3508
+ * Returns an Object containing the prop name/value pairs on the element
3509
+ */
3510
+ Wrapper . prototype . props = function props ( ) {
3511
+ if ( ! this . isVueComponent ) {
3512
+ throwError ( 'wrapper.props() must be called on a Vue instance' ) ;
3513
+ }
3514
+ // $props object does not exist in Vue 2.1.x, so use $options.propsData instead
3515
+ var _props ;
3516
+ if ( this . vm && this . vm . $options && this . vm . $options . propsData ) {
3517
+ _props = this . vm . $options . propsData ;
3518
+ } else {
3519
+ // $FlowIgnore
3520
+ _props = this . vm . $props ;
3521
+ }
3522
+ return _props || { } // Return an empty object if no props exist
3523
+ } ;
3524
+
3439
3525
/**
3440
3526
* Sets vm data
3441
3527
*/
@@ -3949,7 +4035,7 @@ var config = {
3949
4035
}
3950
4036
} ;
3951
4037
3952
- //
4038
+ //
3953
4039
function getStubs ( optionStubs ) {
3954
4040
if ( optionStubs || Object . keys ( config . stubs ) . length > 0 ) {
3955
4041
if ( Array . isArray ( optionStubs ) ) {
@@ -3989,7 +4075,7 @@ function deleteMountingOptions (options) {
3989
4075
delete options . listeners ;
3990
4076
}
3991
4077
3992
- //
4078
+ //
3993
4079
3994
4080
function isValidSlot ( slot ) {
3995
4081
return Array . isArray ( slot ) || ( slot !== null && typeof slot === 'object' ) || typeof slot === 'string'
@@ -4092,7 +4178,7 @@ function createConstructor (
4092
4178
return vm
4093
4179
}
4094
4180
4095
- //
4181
+ //
4096
4182
4097
4183
function createElement ( ) {
4098
4184
if ( document ) {
@@ -4120,7 +4206,7 @@ if (!Element.prototype.matches) {
4120
4206
} ;
4121
4207
}
4122
4208
4123
- //
4209
+ //
4124
4210
4125
4211
Vue . config . productionTip = false ;
4126
4212
Vue . config . errorHandler = errorHandler ;
@@ -4147,7 +4233,7 @@ function mount (component, options) {
4147
4233
return new VueWrapper ( vm , { attachedToDocument : ! ! options . attachToDocument } )
4148
4234
}
4149
4235
4150
- //
4236
+ //
4151
4237
4152
4238
function shallow ( component , options ) {
4153
4239
if ( options === void 0 ) options = { } ;
0 commit comments