From 37dd84c6de9e06e80f68a3aadd2bc489f1073e08 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sun, 7 Dec 2014 01:31:07 -0600 Subject: [PATCH] fix(view): do not register abstract states Closes #2642 --- js/angular/service/history.js | 7 +++++-- test/unit/angular/service/history.unit.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/js/angular/service/history.js b/js/angular/service/history.js index 066d143148..df7eea6cce 100644 --- a/js/angular/service/history.js +++ b/js/angular/service/history.js @@ -284,7 +284,7 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ // create an element from the viewLocals template ele = $ionicViewSwitcher.createViewEle(viewLocals); - if (this.isAbstractEle(ele)) { + if (this.isAbstractEle(ele, viewLocals)) { console.log('VIEW', 'abstractView', DIRECTION_NONE, viewHistory.currentView); return { action: 'abstractView', @@ -651,7 +651,10 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $ return nextViewOptions; }, - isAbstractEle: function(ele) { + isAbstractEle: function(ele, viewLocals) { + if (viewLocals && viewLocals.$$state && viewLocals.$$state.self.abstract) { + return true; + } return !!(ele && (isAbstractTag(ele) || isAbstractTag(ele.children()))); }, diff --git a/test/unit/angular/service/history.unit.js b/test/unit/angular/service/history.unit.js index bd493af3a2..dc176447de 100644 --- a/test/unit/angular/service/history.unit.js +++ b/test/unit/angular/service/history.unit.js @@ -1078,6 +1078,25 @@ describe('Ionic History', function() { expect($ionicHistory.isAbstractEle(div)).toBe(true); })); + it('should should be an abstract element from the viewLocals', inject(function($ionicHistory, $document) { + var div = angular.element('
'); + var viewLocals = { + $$state: { + self: { + abstract: true + } + } + }; + expect($ionicHistory.isAbstractEle(div, viewLocals)).toBe(true); + + var viewLocals = { + $$state: { + self: {} + } + }; + expect($ionicHistory.isAbstractEle(div, viewLocals)).toBe(false); + })); + it('should be an abstract view', inject(function($document) { var reg = ionicHistory.register({}, { $template: ''