@@ -456,16 +456,11 @@ module.service('rowSorter', ['$parse', 'uiGridConstants', function ($parse, uiGr
456456
457457 sortFn = rowSorter . getSortFn ( grid , col , r ) ;
458458
459- var propA , propB ;
460-
461- if ( col . sortCellFiltered ) {
462- propA = grid . getCellDisplayValue ( rowA , col ) ;
463- propB = grid . getCellDisplayValue ( rowB , col ) ;
464- } else {
465- propA = grid . getCellValue ( rowA , col ) ;
466- propB = grid . getCellValue ( rowB , col ) ;
467- }
468-
459+ // Webpack's compress will hoist and combine propA, propB into one var and break sorting functionality
460+ // Wrapping in function prevents that unexpected behavior
461+ var props = getCellValues ( grid , rowA , rowB , col ) ;
462+ var propA = props [ 0 ] ;
463+ var propB = props [ 1 ] ;
469464 tem = sortFn ( propA , propB , rowA , rowB , direction , col ) ;
470465
471466 idx ++ ;
@@ -498,6 +493,20 @@ module.service('rowSorter', ['$parse', 'uiGridConstants', function ($parse, uiGr
498493 return newRows ;
499494 } ;
500495
496+ function getCellValues ( grid , rowA , rowB , col ) {
497+ var propA , propB ;
498+
499+ if ( col . sortCellFiltered ) {
500+ propA = grid . getCellDisplayValue ( rowA , col ) ;
501+ propB = grid . getCellDisplayValue ( rowB , col ) ;
502+ } else {
503+ propA = grid . getCellValue ( rowA , col ) ;
504+ propB = grid . getCellValue ( rowB , col ) ;
505+ }
506+
507+ return [ propA , propB ] ;
508+ }
509+
501510 return rowSorter ;
502511} ] ) ;
503512
0 commit comments