mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(delegate): find delegate when multiple parent histories
This commit is contained in:
13
js/angular/service/history.js
vendored
13
js/angular/service/history.js
vendored
@@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user