From 8bb9e27a2986725f45daf44c4c9f846385095aff Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Mon, 23 Dec 2013 22:48:41 +0100 Subject: [PATCH] fix(uiView): it should autoscroll when expr is missing. --- src/viewDirective.js | 4 ++-- test/viewDirectiveSpec.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/viewDirective.js b/src/viewDirective.js index 2eea2a46d..99f6b0cf3 100644 --- a/src/viewDirective.js +++ b/src/viewDirective.js @@ -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. @@ -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(); } } diff --git a/test/viewDirectiveSpec.js b/test/viewDirectiveSpec.js index 087d71e14..b96d019a9 100644 --- a/test/viewDirectiveSpec.js +++ b/test/viewDirectiveSpec.js @@ -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('
')(scope)); $state.transitionTo(gState); $q.flush(); expect($anchorScroll).toHaveBeenCalled(); })); + it('should autoscroll when expr is missing', inject(function ($state, $q, $anchorScroll) { + elem.append($compile('
')(scope)); + $state.transitionTo(gState); + $q.flush(); + expect($anchorScroll).toHaveBeenCalled(); + })); + it('should autoscroll when truthy', inject(function ($state, $q, $anchorScroll) { elem.append($compile('
')(scope)); $state.transitionTo(gState);