@@ -78,22 +78,25 @@ export default class Wrapper implements BaseWrapper {
7878 /**
7979 * Returns an Object containing all the attribute/value pairs on the element.
8080 */
81- attributes ( ) : { [ name : string ] : string } {
81+ attributes ( key ? : string ) : { [ name : string ] : string } | string {
8282 const attributes = this . element . attributes
8383 const attributeMap = { }
8484 for ( let i = 0 ; i < attributes . length ; i ++ ) {
8585 const att = attributes . item ( i )
8686 attributeMap [ att . localName ] = att . value
8787 }
88+ if ( key ) {
89+ return attributeMap [ key ]
90+ }
8891 return attributeMap
8992 }
9093
9194 /**
9295 * Returns an Array containing all the classes on the element
9396 */
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 ( ' ' ) : [ ]
97100 // Handle converting cssmodules identifiers back to the original class name
98101 if ( this . vm && this . vm . $style ) {
99102 const cssModuleIdentifiers = Object . keys ( this . vm . $style )
@@ -106,9 +109,17 @@ export default class Wrapper implements BaseWrapper {
106109 return acc
107110 } , { } )
108111 classes = classes . map (
109- className => cssModuleIdentifiers [ className ] || className
112+ name => cssModuleIdentifiers [ name ] || name
110113 )
111114 }
115+
116+ if ( className ) {
117+ if ( classes . indexOf ( className ) > - 1 ) {
118+ return true
119+ } else {
120+ return false
121+ }
122+ }
112123 return classes
113124 }
114125
@@ -436,7 +447,7 @@ export default class Wrapper implements BaseWrapper {
436447 /**
437448 * Returns an Object containing the prop name/value pairs on the element
438449 */
439- props ( ) : { [ name : string ] : any } {
450+ props ( key ? : string ) : { [ name : string ] : any } | any {
440451 if ( this . isFunctionalComponent ) {
441452 throwError (
442453 `wrapper.props() cannot be called on a mounted ` +
@@ -457,6 +468,11 @@ export default class Wrapper implements BaseWrapper {
457468 }
458469 } )
459470 }
471+
472+ if ( key ) {
473+ return props [ key ]
474+ }
475+
460476 return props
461477 }
462478
@@ -468,6 +484,7 @@ export default class Wrapper implements BaseWrapper {
468484 throwError ( 'wrapper.setChecked() must be passed a boolean' )
469485 }
470486 const tagName = this . element . tagName
487+ // $FlowIgnore
471488 const type = this . attributes ( ) . type
472489
473490 if ( tagName === 'SELECT' ) {
@@ -515,6 +532,7 @@ export default class Wrapper implements BaseWrapper {
515532 */
516533 setSelected ( ) : void {
517534 const tagName = this . element . tagName
535+ // $FlowIgnore
518536 const type = this . attributes ( ) . type
519537
520538 if ( tagName === 'OPTION' ) {
@@ -744,6 +762,7 @@ export default class Wrapper implements BaseWrapper {
744762 */
745763 setValue ( value : any ) : void {
746764 const tagName = this . element . tagName
765+ // $FlowIgnore
747766 const type = this . attributes ( ) . type
748767
749768 if ( tagName === 'SELECT' ) {
0 commit comments