Skip to content

Commit

Permalink
fix(uiView): it should autoscroll when expr is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Dec 23, 2013
1 parent 5fd1efc commit 8bb9e27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/viewDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @restrict ECA
*
* @description
* The ui-view directive tells $state where to place your templates.
* The ui-view directive tells $state where to place your templates.
* A view can be unnamed or named.
*
* @param {string} ui-view A view name.
Expand Down Expand Up @@ -123,7 +123,7 @@ function $ViewDirective( $state, $compile, $controller, $injector, $an

// TODO: This seems strange, shouldn't $anchorScroll listen for $viewContentLoaded if necessary?
// $anchorScroll might listen on event...
if (!angular.isDefined(attr.autoscroll) || scope.$eval(attr.autoscroll)) {
if (!angular.isDefined(attr.autoscroll) || (!attr.autoscroll || scope.$eval(attr.autoscroll))) {
$anchorScroll();
}
}
Expand Down
9 changes: 8 additions & 1 deletion test/viewDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,20 @@ describe('uiView', function () {
});

describe('autoscroll attribute', function () {
it('should autoscroll when missing', inject(function ($state, $q, $anchorScroll) {
it('should autoscroll when unspecified', inject(function ($state, $q, $anchorScroll) {
elem.append($compile('<div ui-view></div>')(scope));
$state.transitionTo(gState);
$q.flush();
expect($anchorScroll).toHaveBeenCalled();
}));

it('should autoscroll when expr is missing', inject(function ($state, $q, $anchorScroll) {
elem.append($compile('<div ui-view autoscroll></div>')(scope));
$state.transitionTo(gState);
$q.flush();
expect($anchorScroll).toHaveBeenCalled();
}));

it('should autoscroll when truthy', inject(function ($state, $q, $anchorScroll) {
elem.append($compile('<div ui-view autoscroll="true"></div>')(scope));
$state.transitionTo(gState);
Expand Down

0 comments on commit 8bb9e27

Please sign in to comment.