From 7fd31b6aed4dbe132566071f54b5a7cbf6ab46cb Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Tue, 29 Apr 2014 09:17:10 -0600 Subject: [PATCH] fix(ionHeaderBar): have no side effects with content in other views Closes #1095 --- js/angular/directive/headerFooterBar.js | 18 +++++++++--------- js/angular/directive/tabs.js | 3 ++- test/html/viewState.html | 3 +++ .../angular/directive/headerFooterBar.unit.js | 6 +++--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/js/angular/directive/headerFooterBar.js b/js/angular/directive/headerFooterBar.js index d93b517a64e..1218e96c425 100644 --- a/js/angular/directive/headerFooterBar.js +++ b/js/angular/directive/headerFooterBar.js @@ -88,7 +88,7 @@ function tapScrollToTopDirective() { current.tagName.match(/input|textarea|select/i) || current.isContentEditable) { return; - } + } current = current.parentNode; } var touch = e.gesture && e.gesture.touches[0] || e.detail.touches[0]; @@ -121,26 +121,26 @@ function headerFooterBarDirective(isHeader) { }); var el = $element[0]; - //just incase header is on rootscope - var parentScope = $scope.$parent || $scope; if (isHeader) { $scope.$watch(function() { return el.className; }, function(value) { var isSubheader = value.indexOf('bar-subheader') !== -1; - parentScope.$hasHeader = !isSubheader; - parentScope.$hasSubheader = isSubheader; + $scope.$hasHeader = !isSubheader; + $scope.$hasSubheader = isSubheader; }); $scope.$on('$destroy', function() { - parentScope.$hasHeader = parentScope.$hasSubheader = null; + delete $scope.$hasHeader; + delete $scope.$hasSubheader; }); } else { $scope.$watch(function() { return el.className; }, function(value) { var isSubfooter = value.indexOf('bar-subfooter') !== -1; - parentScope.$hasFooter = !isSubfooter; - parentScope.$hasSubfooter = isSubfooter; + $scope.$hasFooter = !isSubfooter; + $scope.$hasSubfooter = isSubfooter; }); $scope.$on('$destroy', function() { - parentScope.$hasFooter = parentScope.$hasSubfooter = null; + delete $scope.$hasFooter; + delete $scope.$hasSubfooter; }); $scope.$watch('$hasTabs', function(val) { $element.toggleClass('has-tabs', !!val); diff --git a/js/angular/directive/tabs.js b/js/angular/directive/tabs.js index 67c354be135..aa14569ada5 100644 --- a/js/angular/directive/tabs.js +++ b/js/angular/directive/tabs.js @@ -75,7 +75,8 @@ IonicModule $scope.$hasTabsTop = isTabsTop && !isHidden; }); $scope.$on('$destroy', function() { - $scope.$hasTabs = $scope.$hasTabsTop = null; + delete $scope.$hasTabs; + delete $scope.$hasTabsTop; }); } } diff --git a/test/html/viewState.html b/test/html/viewState.html index 711b31456ef..16ab9d04d9f 100644 --- a/test/html/viewState.html +++ b/test/html/viewState.html @@ -172,6 +172,9 @@

Information

+ +

some subheader

+