Skip to content

Commit c33e924

Browse files
author
Devin Fields
committed
fix(rowSorter.js): wrap rowSortFn while innards in IIFE to prevent issue with webpack compress.
1 parent 7afc3d0 commit c33e924

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/js/core/services/rowSorter.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,21 @@ 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-
469-
tem = sortFn(propA, propB, rowA, rowB, direction, col);
459+
// Webpack's compress will hoist and combine propA, propB into one var and break sorting functionality
460+
// Wrapping in IIFE prevents that unexpected behavior
461+
(function () {
462+
var propA, propB;
463+
464+
if ( col.sortCellFiltered ){
465+
propA = grid.getCellDisplayValue(rowA, col);
466+
propB = grid.getCellDisplayValue(rowB, col);
467+
} else {
468+
propA = grid.getCellValue(rowA, col);
469+
propB = grid.getCellValue(rowB, col);
470+
}
471+
472+
tem = sortFn(propA, propB, rowA, rowB, direction, col);
473+
})();
470474

471475
idx++;
472476
}

0 commit comments

Comments
 (0)