@@ -78,22 +78,25 @@ export default class Wrapper implements BaseWrapper {
78
78
/**
79
79
* Returns an Object containing all the attribute/value pairs on the element.
80
80
*/
81
- attributes ( ) : { [ name : string ] : string } {
81
+ attributes ( key ? : string ) : { [ name : string ] : string } | string {
82
82
const attributes = this . element . attributes
83
83
const attributeMap = { }
84
84
for ( let i = 0 ; i < attributes . length ; i ++ ) {
85
85
const att = attributes . item ( i )
86
86
attributeMap [ att . localName ] = att . value
87
87
}
88
+ if ( key ) {
89
+ return attributeMap [ key ]
90
+ }
88
91
return attributeMap
89
92
}
90
93
91
94
/**
92
95
* Returns an Array containing all the classes on the element
93
96
*/
94
- classes ( ) : Array < string > {
95
- const className = this . element . getAttribute ( 'class' )
96
- let classes = className ? className . split ( ' ' ) : [ ]
97
+ classes ( className ? : string ) : Array < string > | boolean {
98
+ const classAttribute = this . element . getAttribute ( 'class' )
99
+ let classes = classAttribute ? classAttribute . split ( ' ' ) : [ ]
97
100
// Handle converting cssmodules identifiers back to the original class name
98
101
if ( this . vm && this . vm . $style ) {
99
102
const cssModuleIdentifiers = Object . keys ( this . vm . $style )
@@ -106,9 +109,17 @@ export default class Wrapper implements BaseWrapper {
106
109
return acc
107
110
} , { } )
108
111
classes = classes . map (
109
- className => cssModuleIdentifiers [ className ] || className
112
+ name => cssModuleIdentifiers [ name ] || name
110
113
)
111
114
}
115
+
116
+ if ( className ) {
117
+ if ( classes . indexOf ( className ) > - 1 ) {
118
+ return true
119
+ } else {
120
+ return false
121
+ }
122
+ }
112
123
return classes
113
124
}
114
125
@@ -436,7 +447,7 @@ export default class Wrapper implements BaseWrapper {
436
447
/**
437
448
* Returns an Object containing the prop name/value pairs on the element
438
449
*/
439
- props ( ) : { [ name : string ] : any } {
450
+ props ( key ? : string ) : { [ name : string ] : any } | any {
440
451
if ( this . isFunctionalComponent ) {
441
452
throwError (
442
453
`wrapper.props() cannot be called on a mounted ` +
@@ -457,6 +468,11 @@ export default class Wrapper implements BaseWrapper {
457
468
}
458
469
} )
459
470
}
471
+
472
+ if ( key ) {
473
+ return props [ key ]
474
+ }
475
+
460
476
return props
461
477
}
462
478
@@ -468,6 +484,7 @@ export default class Wrapper implements BaseWrapper {
468
484
throwError ( 'wrapper.setChecked() must be passed a boolean' )
469
485
}
470
486
const tagName = this . element . tagName
487
+ // $FlowIgnore
471
488
const type = this . attributes ( ) . type
472
489
473
490
if ( tagName === 'SELECT' ) {
@@ -515,6 +532,7 @@ export default class Wrapper implements BaseWrapper {
515
532
*/
516
533
setSelected ( ) : void {
517
534
const tagName = this . element . tagName
535
+ // $FlowIgnore
518
536
const type = this . attributes ( ) . type
519
537
520
538
if ( tagName === 'OPTION' ) {
@@ -744,6 +762,7 @@ export default class Wrapper implements BaseWrapper {
744
762
*/
745
763
setValue ( value : any ) : void {
746
764
const tagName = this . element . tagName
765
+ // $FlowIgnore
747
766
const type = this . attributes ( ) . type
748
767
749
768
if ( tagName === 'SELECT' ) {
0 commit comments