1
1
/*!
2
- * ui-grid - v4.0.1 - 2016-12-15
2
+ * ui-grid - v4.0.1-138d149 - 2016-12-29
3
3
* Copyright (c) 2016 ; License: MIT
4
4
*/
5
5
@@ -2273,13 +2273,11 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
2273
2273
angular.element($window).on('resize', applyHideMenu);
2274
2274
}
2275
2275
2276
- $scope.$on('$destroy', function () {
2277
- angular.element(document).off('click touchstart', applyHideMenu);
2278
- });
2279
-
2280
-
2281
- $scope.$on('$destroy', function() {
2276
+ $scope.$on('$destroy', function unbindEvents() {
2282
2277
angular.element($window).off('resize', applyHideMenu);
2278
+ angular.element(document).off('click touchstart', applyHideMenu);
2279
+ $elm.off('keyup', checkKeyUp);
2280
+ $elm.off('keydown', checkKeyDown);
2283
2281
});
2284
2282
2285
2283
if (uiGridCtrl) {
@@ -3214,7 +3212,9 @@ function ($compile, $timeout, $window, $document, gridUtil, uiGridConstants, i18
3214
3212
}
3215
3213
}
3216
3214
3217
-
3215
+ $scope.$on('$destroy', function unbindEvents() {
3216
+ $elm.off();
3217
+ });
3218
3218
},
3219
3219
controller: ['$scope', function ($scope) {
3220
3220
this.rowStyle = function (index) {
@@ -4784,7 +4784,7 @@ angular.module('ui.grid')
4784
4784
* @methodOf ui.grid.class:Grid
4785
4785
* @description returns the GridRow that contains the rowEntity
4786
4786
* @param {object} rowEntity the gridOptions.data array element instance
4787
- * @param {array} rows [optional] the rows to look in - if not provided then
4787
+ * @param {array} lookInRows [optional] the rows to look in - if not provided then
4788
4788
* looks in grid.rows
4789
4789
*/
4790
4790
Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
@@ -4849,13 +4849,20 @@ angular.module('ui.grid')
4849
4849
self.rows.length = 0;
4850
4850
4851
4851
newRawData.forEach( function( newEntity, i ) {
4852
- var newRow;
4852
+ var newRow, oldRow;
4853
+
4853
4854
if ( self.options.enableRowHashing ){
4854
4855
// if hashing is enabled, then this row will be in the hash if we already know about it
4855
- newRow = oldRowHash.get( newEntity );
4856
+ oldRow = oldRowHash.get( newEntity );
4856
4857
} else {
4857
4858
// otherwise, manually search the oldRows to see if we can find this row
4858
- newRow = self.getRow(newEntity, oldRows);
4859
+ oldRow = self.getRow(newEntity, oldRows);
4860
+ }
4861
+
4862
+ // update newRow to have an entity
4863
+ if ( oldRow ) {
4864
+ newRow = oldRow;
4865
+ newRow.entity = newEntity;
4859
4866
}
4860
4867
4861
4868
// if we didn't find the row, it must be new, so create it
@@ -11786,6 +11793,11 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
11786
11793
for ( var i = mouseWheeltoBind.length; i; ) {
11787
11794
$elm.on(mouseWheeltoBind[--i], cbs[fn]);
11788
11795
}
11796
+ $elm.on('$destroy', function unbindEvents() {
11797
+ for ( var i = mouseWheeltoBind.length; i; ) {
11798
+ $elm.off(mouseWheeltoBind[--i], cbs[fn]);
11799
+ }
11800
+ });
11789
11801
};
11790
11802
s.off.mousewheel = function (elm, fn) {
11791
11803
var $elm = angular.element(elm);
@@ -16436,7 +16448,11 @@ module.filter('px', function() {
16436
16448
});
16437
16449
16438
16450
16439
- $scope.$on( '$destroy', rowWatchDereg );
16451
+ $scope.$on('$destroy', function destroyEvents() {
16452
+ rowWatchDereg();
16453
+ // unbind all jquery events in order to avoid memory leaks
16454
+ $elm.off();
16455
+ });
16440
16456
16441
16457
function registerBeginEditEvents() {
16442
16458
$elm.on('dblclick', beginEdit);
@@ -16971,6 +16987,11 @@ module.filter('px', function() {
16971
16987
16972
16988
return true;
16973
16989
});
16990
+
16991
+ $scope.$on('$destroy', function unbindEvents() {
16992
+ // unbind all jquery events in order to avoid memory leaks
16993
+ $elm.off();
16994
+ });
16974
16995
}
16975
16996
};
16976
16997
}
@@ -17114,6 +17135,11 @@ module.filter('px', function() {
17114
17135
}
17115
17136
return true;
17116
17137
});
17138
+
17139
+ $scope.$on('$destroy', function unbindEvents() {
17140
+ // unbind jquery events to prevent memory leaks
17141
+ $elm.off();
17142
+ });
17117
17143
}
17118
17144
};
17119
17145
}
@@ -17206,7 +17232,7 @@ module.filter('px', function() {
17206
17232
}
17207
17233
};
17208
17234
17209
- $elm[0].addEventListener('change', handleFileSelect, false); // TODO: why the false on the end? Google
17235
+ $elm[0].addEventListener('change', handleFileSelect, false);
17210
17236
17211
17237
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
17212
17238
$elm[0].focus();
@@ -17216,13 +17242,17 @@ module.filter('px', function() {
17216
17242
$scope.$emit(uiGridEditConstants.events.END_CELL_EDIT);
17217
17243
});
17218
17244
});
17245
+
17246
+ $scope.$on('$destroy', function unbindEvents() {
17247
+ // unbind jquery events to prevent memory leaks
17248
+ $elm.off();
17249
+ $elm[0].removeEventListener('change', handleFileSelect, false);
17250
+ });
17219
17251
}
17220
17252
};
17221
17253
}
17222
17254
};
17223
17255
}]);
17224
-
17225
-
17226
17256
})();
17227
17257
17228
17258
(function () {
@@ -22385,6 +22415,8 @@ module.filter('px', function() {
22385
22415
movingElm.css({'width': reducedWidth + 'px'});
22386
22416
}
22387
22417
};
22418
+
22419
+ $scope.$on('$destroy', offAllEvents);
22388
22420
}
22389
22421
}
22390
22422
};
@@ -25966,6 +25998,10 @@ module.filter('px', function() {
25966
25998
window.setTimeout(function () { evt.target.onselectstart = null; }, 0);
25967
25999
}
25968
26000
}
26001
+
26002
+ $scope.$on('$destroy', function unbindEvents() {
26003
+ $elm.off();
26004
+ });
25969
26005
}
25970
26006
};
25971
26007
}]);
0 commit comments