mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
fix(gridster): ensure coords instances are destroyed on widgets
…when removing a widget, or when destroying the gridster instance. Before this change, if you called destroy without `remove` set to true, coords instances was leaking jQuery data objects. Also nullified the gridmap, and faux_grid arrays.
This commit is contained in:
@@ -747,6 +747,7 @@
|
||||
|
||||
$el[this.options.hide_method]({
|
||||
always: $.proxy(function() {
|
||||
$el.coords().destroy();
|
||||
$el.remove();
|
||||
|
||||
if (!silent) {
|
||||
@@ -3123,6 +3124,11 @@
|
||||
*/
|
||||
fn.destroy = function(remove) {
|
||||
this.$el.removeData('gridster');
|
||||
this.$widgets.each($.proxy(function(i, el){
|
||||
$(el).coords().destroy();
|
||||
}, this));
|
||||
this.gridmap = null;
|
||||
this.faux_grid = null;
|
||||
|
||||
// remove bound callback on window resize
|
||||
$(window).unbind('.gridster');
|
||||
|
||||
+2
-2
@@ -328,8 +328,8 @@ describe('gridster.js', function() {
|
||||
|
||||
it('should clean gridmap array', function() {
|
||||
this.gridster.destroy();
|
||||
expect(this.gridster.gridmap).to.be.empty;
|
||||
expect(this.gridster.faux_grid).to.be.empty;
|
||||
expect(this.gridster.gridmap).to.not.have.length;
|
||||
expect(this.gridster.faux_grid).to.not.have.length;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user