File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 " react-search-input.js" ,
55 " react-search-input.css"
66 ],
7- "version" : " 0.2.4 " ,
7+ "version" : " 0.2.5 " ,
88 "homepage" : " https://github.com/enki-com/react-search-input" ,
99 "description" : " Simple react.js component for a search input, providing a filter function." ,
1010 "keywords" : [
Original file line number Diff line number Diff line change 11{
22 "name" : " react-search-input" ,
3- "version" : " 0.2.4 " ,
3+ "version" : " 0.2.5 " ,
44 "description" : " Simple react.js component for a search input, providing a filter function." ,
55 "main" : " react-search-input.js" ,
66 "dependencies" : {
Original file line number Diff line number Diff line change 7878 term = term . toLowerCase ( ) ;
7979 }
8080
81- if ( keys ) {
82- if ( typeof keys === 'string' ) {
83- keys = [ keys ] ;
84- }
85- for ( var i = 0 ; i < keys . length ; i ++ ) {
86- var values = _getValuesForKey ( keys [ i ] , item ) ;
81+ var terms = term . split ( ' ' ) ;
82+ var foundCount = 0 ;
83+ terms . forEach ( function ( term ) {
84+ if ( keys ) {
85+ if ( typeof keys === 'string' ) {
86+ keys = [ keys ] ;
87+ }
8788 var found = false ;
88- values . forEach ( function ( value ) {
89- try {
90- if ( value && value . search ( term ) !== - 1 ) {
91- found = true ;
92- }
93- } catch ( e ) {
89+ for ( var i = 0 ; i < keys . length ; i ++ ) {
90+ var values = _getValuesForKey ( keys [ i ] , item ) ;
91+ values . forEach ( function ( value ) {
92+ try {
93+ if ( value && value . search ( term ) !== - 1 ) {
94+ found = true ;
95+ }
96+ } catch ( e ) { }
97+ } ) ;
98+ if ( found ) {
99+ break ;
94100 }
95- } ) ;
101+ }
102+
96103 if ( found ) {
97- return true ;
104+ foundCount ++ ;
98105 }
106+ } else {
107+ try {
108+ var stringValue = item . toLowerCase ( ) ;
109+ if ( stringValue . search ( term ) !== - 1 ) {
110+ foundCount ++ ;
111+ }
112+ } catch ( e ) { }
99113 }
100- return false ;
101- } else {
102- try {
103- var stringValue = item . toLowerCase ( ) ;
104- return ( stringValue . search ( term ) !== - 1 ) ;
105- } catch ( e ) {
106- return false ;
107- }
108- }
109- } . bind ( this ) ;
114+ } ) ;
115+ return foundCount === terms . length ; ;
116+ } ;
110117 }
111118 }
112119 } ) ;
You can’t perform that action at this time.
0 commit comments