Skip to content

Commit 37dd84c

Browse files
committed
fix(view): do not register abstract states
Closes ionic-team#2642
1 parent cf2556b commit 37dd84c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

js/angular/service/history.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
284284

285285
// create an element from the viewLocals template
286286
ele = $ionicViewSwitcher.createViewEle(viewLocals);
287-
if (this.isAbstractEle(ele)) {
287+
if (this.isAbstractEle(ele, viewLocals)) {
288288
console.log('VIEW', 'abstractView', DIRECTION_NONE, viewHistory.currentView);
289289
return {
290290
action: 'abstractView',
@@ -651,7 +651,10 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
651651
return nextViewOptions;
652652
},
653653

654-
isAbstractEle: function(ele) {
654+
isAbstractEle: function(ele, viewLocals) {
655+
if (viewLocals && viewLocals.$$state && viewLocals.$$state.self.abstract) {
656+
return true;
657+
}
655658
return !!(ele && (isAbstractTag(ele) || isAbstractTag(ele.children())));
656659
},
657660

test/unit/angular/service/history.unit.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,25 @@ describe('Ionic History', function() {
10781078
expect($ionicHistory.isAbstractEle(div)).toBe(true);
10791079
}));
10801080

1081+
it('should should be an abstract element from the viewLocals', inject(function($ionicHistory, $document) {
1082+
var div = angular.element('<div>');
1083+
var viewLocals = {
1084+
$$state: {
1085+
self: {
1086+
abstract: true
1087+
}
1088+
}
1089+
};
1090+
expect($ionicHistory.isAbstractEle(div, viewLocals)).toBe(true);
1091+
1092+
var viewLocals = {
1093+
$$state: {
1094+
self: {}
1095+
}
1096+
};
1097+
expect($ionicHistory.isAbstractEle(div, viewLocals)).toBe(false);
1098+
}));
1099+
10811100
it('should be an abstract view', inject(function($document) {
10821101
var reg = ionicHistory.register({}, {
10831102
$template: '<ion-tabs></ion-tabs>'

0 commit comments

Comments
 (0)