File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 354354 }
355355
356356 return function ( query ) {
357- var t = query . term , filtered = { } ;
357+ var t = query . term , filtered = { results : [ ] } , process ;
358358 if ( t === "" ) {
359359 query . callback ( { results : data } ) ;
360360 return ;
361361 }
362- filtered . results = $ ( data )
363- . filter ( function ( ) { return query . matcher ( t , text ( this ) ) ; } )
364- . get ( ) ;
362+
363+ process = function ( datum , collection ) {
364+ var group ;
365+ datum = datum [ 0 ] ;
366+ if ( datum . children ) {
367+ group = { text : text ( datum ) , children : [ ] } ;
368+ $ ( datum . children ) . each2 ( function ( i , childDatum ) { process ( childDatum , group . children ) ; } ) ;
369+ if ( group . children . length ) {
370+ collection . push ( group ) ;
371+ }
372+ } else {
373+ if ( query . matcher ( t , text ( datum ) ) ) {
374+ collection . push ( datum ) ;
375+ }
376+ }
377+ } ;
378+
379+ $ ( data ) . each2 ( function ( i , datum ) { process ( datum , filtered . results ) ; } ) ;
365380 query . callback ( filtered ) ;
366381 } ;
367382 }
You can’t perform that action at this time.
0 commit comments