File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,11 +36,18 @@ export default function find(selector){
3636
3737 // data attribute
3838 case '[' :
39+ var attributeName = _ . first ( subselector . slice ( 1 , - 1 ) . split ( '=' ) )
40+ var attributeValue = subselector . slice ( 1 , - 1 ) . split ( '=' ) . slice ( 1 ) . join ( '=' ) . replace ( / ^ " ( .* ) " $ / , '$1' )
41+
3942 els = TestUtils . findAllInRenderedTree ( self . instance , function ( component ) {
4043 if ( component . getAttribute ) {
41- return component . getAttribute ( subselector . slice ( 1 , - 1 ) )
44+ var val = component . getAttribute ( attributeName )
45+ if ( val === attributeValue || ( val === 'true' && attributeValue === '' ) ) {
46+ return true
47+ }
4248 }
4349 } )
50+
4451 foundElements . push ( Array . isArray ( els ) ? els : [ els ] )
4552 break
4653
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ export default class TestComponent extends Component {
2323 onClick = { this . props . onClick } >
2424 Click Me
2525 </ button >
26- < input name = "bob" />
26+ < input className = "notbob" name />
27+ < input className = "bob" name = "bob" />
2728 < TinyComponent test = "true" />
2829 < OtherComponent test = "true" />
2930 </ section >
Original file line number Diff line number Diff line change @@ -41,8 +41,10 @@ describe('Find middleware', () => {
4141 it ( 'should find an input with a name attribute that equals \'bob\'' , ( ) => {
4242 Test ( < TestComponent /> )
4343 . find ( 'input[name="bob"]' )
44+ . find ( 'input[name]' )
4445 . test ( function ( ) {
45- expect ( this . elements [ '[input[name="bob"]' ] ) . to . not . equal ( undefined )
46+ expect ( this . elements [ 'input[name="bob"]' ] . className ) . equal ( 'bob' )
47+ expect ( this . elements [ 'input[name]' ] . className ) . equal ( 'notbob' )
4648 } )
4749 } )
4850
You can’t perform that action at this time.
0 commit comments