mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
amend(platform-backButton): do not set icon if icon child exists
This commit is contained in:
4
js/angular/directive/navBackButton.js
vendored
4
js/angular/directive/navBackButton.js
vendored
@@ -80,10 +80,12 @@ function($animate, $rootScope, $sanitize, $ionicNavBarConfig, $ionicNgClick) {
|
||||
compile: function(tElement, tAttrs) {
|
||||
tElement.addClass('button back-button ng-hide');
|
||||
|
||||
var hasIconChild = !!(tElement.html() || '').match(/class=.*?ion-/);
|
||||
|
||||
return function($scope, $element, $attr, navBarCtrl) {
|
||||
|
||||
// Add a default back button icon based on the nav config, unless one is set
|
||||
if($element[0].className.indexOf('ion-') < 0) {
|
||||
if (!hasIconChild && $element[0].className.indexOf('ion-') === -1) {
|
||||
$element.addClass($ionicNavBarConfig.backButtonIcon);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,19 +78,29 @@ describe('ionNavBackButton directive', function() {
|
||||
});
|
||||
|
||||
|
||||
describe('ionNavBackButton directive: Platforms', function() {
|
||||
describe('ionNavBackButton directive: iOS Platform', function() {
|
||||
describe('platforms', function() {
|
||||
describe('iOS', function() {
|
||||
beforeEach(function($provide) {
|
||||
TestUtil.setPlatform('ios');
|
||||
});
|
||||
|
||||
it('should not set default back button icon if icon classname exists', function() {
|
||||
var el = setup('class="ion-navicon"');
|
||||
expect(el.hasClass('ion-ios7-arrow-back')).toBe(false);
|
||||
});
|
||||
|
||||
it('should not set default back button icon if icon child exists', function() {
|
||||
var el = setup('', '<i class="ion-superstar"></i>');
|
||||
expect(el.hasClass('ion-ios7-arrow-back')).toBe(false);
|
||||
});
|
||||
|
||||
it('Should set default back button icon from ionicNavBarConfig ', inject(function($ionicNavBarConfig) {
|
||||
var el = setup();
|
||||
expect(el.hasClass('ion-ios7-arrow-back')).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('ionNavBackButton directive: Android Platform', function() {
|
||||
describe('android', function() {
|
||||
beforeEach(function($provide) {
|
||||
TestUtil.setPlatform('android');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user