Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});