diff --git a/js/ext/angular/src/service/decorators/location.js b/js/ext/angular/src/service/decorators/location.js index 4d1bde139e2..a1cbdf3f582 100644 --- a/js/ext/angular/src/service/decorators/location.js +++ b/js/ext/angular/src/service/decorators/location.js @@ -6,19 +6,17 @@ angular.module('ionic.decorator.location', []) function $LocationDecorator($location, $timeout) { - var firstHashSet = false; $location.__hash = $location.hash; //Fix: first time window.location.hash is set, the scrollable area //found nearest to body's scrollTop is set to scroll to an element //with that ID. $location.hash = function(value) { - if (!firstHashSet && angular.isDefined(value)) { + if (angular.isDefined(value)) { $timeout(function() { var scroll = document.querySelector('.scroll-content'); if (scroll) scroll.scrollTop = 0; }, 0, false); - firstHashSet = true; } return $location.__hash(value); }; diff --git a/js/ext/angular/test/service/decorators/location.unit.js b/js/ext/angular/test/service/decorators/location.unit.js index 1534b645939..d22e8292a17 100644 --- a/js/ext/angular/test/service/decorators/location.unit.js +++ b/js/ext/angular/test/service/decorators/location.unit.js @@ -1,7 +1,7 @@ describe('$location decorator', function() { beforeEach(module('ionic.decorator.location')); - + describe('.hash()', function() { it('should find .scroll-content and set scrollTop=0', inject(function($location, $timeout, $rootScope) { @@ -13,12 +13,6 @@ describe('$location decorator', function() { $location.hash('123'); $timeout.flush(); expect(scroll.scrollTop).toBe(0); - - //Second time? shouldnt try to set things - scroll.scrollTop = 4; - $location.hash('456'); - $timeout.verifyNoPendingTasks(); - expect(scroll.scrollTop).toBe(4); })); });