Skip to content

Commit

Permalink
fix(delegate): find delegate when multiple parent histories
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Nov 25, 2014
1 parent 4f8bbc1 commit 61916c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
13 changes: 4 additions & 9 deletions js/angular/service/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,23 +645,18 @@ function($rootScope, $state, $location, $window, $ionicViewSwitcher, $ionicNavVi
if (!scope) return false;

var climbScope = scope;
var historyId;
var currentHistoryId = this.currentHistoryId();
while (climbScope) {
if (climbScope.$$disconnected) {
return false;
}
if (!historyId && climbScope.hasOwnProperty('$historyId')) {
historyId = climbScope.$historyId;
if (currentHistoryId && currentHistoryId == climbScope.$historyId) {
return true;
}
climbScope = climbScope.$parent;
}

var currentHistoryId = this.currentHistoryId();
if (currentHistoryId) {
return currentHistoryId == (historyId || 'root');
}

return true;
return currentHistoryId ? currentHistoryId == 'root' : true;
}

};
Expand Down
19 changes: 19 additions & 0 deletions test/unit/angular/service/history.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,25 @@ describe('Ionic History', function() {
expect(ionicHistory.isActiveScope(scope)).toEqual(true);
});

it('should be active when one of the parent scopes is the same history id as current view', function() {
ionicHistory.currentView({
historyId: '123'
});

var scope = {
$parent: {
$historyId: 'abc',
$parent: {
$historyId: 'xyz',
$parent: {
$historyId: '123'
}
}
}
}
expect(ionicHistory.isActiveScope(scope)).toEqual(true);
});

it('should be not active w/ scope different history id as current view', function() {
ionicHistory.currentView({
historyId: '123'
Expand Down

0 comments on commit 61916c6

Please sign in to comment.