forked from angular-ui/ui-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cellNav): Don't setup when directive not there
The cellNav feature was attaching logic to render containers and grid cells despite the uiGridCellnav directive not being on the parent grid component. This was causing exception to be thrown during scroll events. This change looks for the cellNav controller (which is simply empty) and bails before attaching logic if the controller is not present. Also added tests to cover the exceptions that were occuring. Fixes angular-ui#2128
- Loading branch information
Showing
2 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe('ui.grid.cellNav directive', function () { | ||
var $scope, $compile, elm, uiGridConstants; | ||
|
||
beforeEach(module('ui.grid.cellNav')); | ||
|
||
beforeEach(inject(function (_$rootScope_, _$compile_, _uiGridConstants_) { | ||
$scope = _$rootScope_; | ||
$compile = _$compile_; | ||
uiGridConstants = _uiGridConstants_; | ||
|
||
$scope.gridOpts = { | ||
data: [{ name: 'Bob' }] | ||
}; | ||
})); | ||
|
||
it('should not throw exceptions when scrolling when a grid does NOT have the ui-grid-cellNav directive', function () { | ||
elm = angular.element('<div ui-grid="gridOpts"></div>'); | ||
|
||
$compile(elm)($scope); | ||
$scope.$digest(); | ||
|
||
expect(function () { | ||
$scope.$broadcast(uiGridConstants.events.GRID_SCROLL, {}); | ||
}).not.toThrow(); | ||
}); | ||
}); |