Skip to content

Commit

Permalink
fix(importer.js): Remove unnecessary on destroy event.
Browse files Browse the repository at this point in the history
Fixing issue which causes importer to not work ever.

fix #6550
  • Loading branch information
Portugal, Marcelo authored and mportuga committed Feb 1, 2018
1 parent f3d2a7f commit 497a554
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
9 changes: 2 additions & 7 deletions src/features/importer/js/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
link: function ($scope, $elm, $attrs, uiGridCtrl) {
var grid;

var handleFileSelect = function( event ){
function handleFileSelect(event) {
var target = event.srcElement || event.target;

if (target && target.files && target.files.length === 1) {
Expand All @@ -744,7 +744,7 @@
gridUtil.logError('Could not import file because UI Grid was not found.');
}
}
};
}

var fileChooser = $elm[0].querySelectorAll('.ui-grid-importer-file-chooser');

Expand All @@ -753,11 +753,6 @@
} else {
fileChooser[0].addEventListener('change', handleFileSelect, false);
}

$scope.$on('$destroy', function unbindEvents() {
// unbind jquery events to prevent memory leaks
fileChooser[0].removeEventListener('change', handleFileSelect, false);
});
}
};
}
Expand Down
12 changes: 0 additions & 12 deletions src/features/importer/test/uiGridImporterMenuItemDirective.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,4 @@ describe('ui.grid.importer uiGridImporterMenuItem', function() {

expect(gridUtil.logError).toHaveBeenCalledWith('Found > 1 or < 1 file choosers within the menu item, error, cannot continue');
});
describe('on $destroy', function() {
beforeEach(function() {
spyOn(fileChooser[0], 'removeEventListener').and.callThrough();
$scope.$broadcast('$destroy');
});
afterEach(function() {
fileChooser[0].removeEventListener.calls.reset();
});
it('should remove all event handlers', function() {
expect(fileChooser[0].removeEventListener).toHaveBeenCalled();
});
});
});

0 comments on commit 497a554

Please sign in to comment.