diff --git a/src/tabs/tabs.js b/src/tabs/tabs.js index cb68c8df39..81d792bdbd 100644 --- a/src/tabs/tabs.js +++ b/src/tabs/tabs.js @@ -238,7 +238,7 @@ angular.module('ui.bootstrap.tabs', []) .directive('uibTabHeadingTransclude', function() { return { restrict: 'A', - require: ['?^uibTab', '?^tab'], // TODO: change to '^uibTab' after deprecation removal + require: '^uibTab', link: function(scope, elm) { scope.$watch('headingElement', function updateHeadingElement(heading) { if (heading) { @@ -253,7 +253,7 @@ angular.module('ui.bootstrap.tabs', []) .directive('uibTabContentTransclude', function() { return { restrict: 'A', - require: ['?^uibTabset', '?^tabset'], // TODO: change to '^uibTabset' after deprecation removal + require: '^uibTabset', link: function(scope, elm, attrs) { var tab = scope.$eval(attrs.uibTabContentTransclude); @@ -274,166 +274,12 @@ angular.module('ui.bootstrap.tabs', []) function isTabHeading(node) { return node.tagName && ( - node.hasAttribute('tab-heading') || // TODO: remove after deprecation removal - node.hasAttribute('data-tab-heading') || // TODO: remove after deprecation removal - node.hasAttribute('x-tab-heading') || // TODO: remove after deprecation removal node.hasAttribute('uib-tab-heading') || node.hasAttribute('data-uib-tab-heading') || node.hasAttribute('x-uib-tab-heading') || - node.tagName.toLowerCase() === 'tab-heading' || // TODO: remove after deprecation removal - node.tagName.toLowerCase() === 'data-tab-heading' || // TODO: remove after deprecation removal - node.tagName.toLowerCase() === 'x-tab-heading' || // TODO: remove after deprecation removal node.tagName.toLowerCase() === 'uib-tab-heading' || node.tagName.toLowerCase() === 'data-uib-tab-heading' || node.tagName.toLowerCase() === 'x-uib-tab-heading' ); } }); - -/* deprecated tabs below */ - -angular.module('ui.bootstrap.tabs') - - .value('$tabsSuppressWarning', false) - - .controller('TabsetController', ['$scope', '$controller', '$log', '$tabsSuppressWarning', function($scope, $controller, $log, $tabsSuppressWarning) { - if (!$tabsSuppressWarning) { - $log.warn('TabsetController is now deprecated. Use UibTabsetController instead.'); - } - - angular.extend(this, $controller('UibTabsetController', { - $scope: $scope - })); - }]) - - .directive('tabset', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) { - return { - restrict: 'EA', - transclude: true, - replace: true, - scope: { - type: '@' - }, - controller: 'TabsetController', - templateUrl: 'template/tabs/tabset.html', - link: function(scope, element, attrs) { - - if (!$tabsSuppressWarning) { - $log.warn('tabset is now deprecated. Use uib-tabset instead.'); - } - scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false; - scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false; - } - }; - }]) - - .directive('tab', ['$parse', '$log', '$tabsSuppressWarning', function($parse, $log, $tabsSuppressWarning) { - return { - require: '^tabset', - restrict: 'EA', - replace: true, - templateUrl: 'template/tabs/tab.html', - transclude: true, - scope: { - active: '=?', - heading: '@', - onSelect: '&select', //This callback is called in contentHeadingTransclude - //once it inserts the tab's content into the dom - onDeselect: '&deselect' - }, - controller: function() { - //Empty controller so other directives can require being 'under' a tab - }, - link: function(scope, elm, attrs, tabsetCtrl, transclude) { - if (!$tabsSuppressWarning) { - $log.warn('tab is now deprecated. Use uib-tab instead.'); - } - - scope.$watch('active', function(active) { - if (active) { - tabsetCtrl.select(scope); - } - }); - - scope.disabled = false; - if (attrs.disable) { - scope.$parent.$watch($parse(attrs.disable), function(value) { - scope.disabled = !!value; - }); - } - - scope.select = function() { - if (!scope.disabled) { - scope.active = true; - } - }; - - tabsetCtrl.addTab(scope); - scope.$on('$destroy', function() { - tabsetCtrl.removeTab(scope); - }); - - //We need to transclude later, once the content container is ready. - //when this link happens, we're inside a tab heading. - scope.$transcludeFn = transclude; - } - }; - }]) - - .directive('tabHeadingTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) { - return { - restrict: 'A', - require: '^tab', - link: function(scope, elm) { - if (!$tabsSuppressWarning) { - $log.warn('tab-heading-transclude is now deprecated. Use uib-tab-heading-transclude instead.'); - } - - scope.$watch('headingElement', function updateHeadingElement(heading) { - if (heading) { - elm.html(''); - elm.append(heading); - } - }); - } - }; - }]) - - .directive('tabContentTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) { - return { - restrict: 'A', - require: '^tabset', - link: function(scope, elm, attrs) { - if (!$tabsSuppressWarning) { - $log.warn('tab-content-transclude is now deprecated. Use uib-tab-content-transclude instead.'); - } - - var tab = scope.$eval(attrs.tabContentTransclude); - - //Now our tab is ready to be transcluded: both the tab heading area - //and the tab content area are loaded. Transclude 'em both. - tab.$transcludeFn(tab.$parent, function(contents) { - angular.forEach(contents, function(node) { - if (isTabHeading(node)) { - //Let tabHeadingTransclude know. - tab.headingElement = node; - } - else { - elm.append(node); - } - }); - }); - } - }; - - function isTabHeading(node) { - return node.tagName && ( - node.hasAttribute('tab-heading') || - node.hasAttribute('data-tab-heading') || - node.hasAttribute('x-tab-heading') || - node.tagName.toLowerCase() === 'tab-heading' || - node.tagName.toLowerCase() === 'data-tab-heading' || - node.tagName.toLowerCase() === 'x-tab-heading' - ); - } - }]); diff --git a/src/tabs/test/tabs.spec.js b/src/tabs/test/tabs.spec.js index 1de3c25e33..cbcd9acf54 100644 --- a/src/tabs/test/tabs.spec.js +++ b/src/tabs/test/tabs.spec.js @@ -853,71 +853,3 @@ describe('tabs', function() { })); }); }); - -/* deprecation tests below */ - -describe('tab deprecation', function() { - beforeEach(module('ui.bootstrap.tabs')); - beforeEach(module('template/tabs/tabset.html')); - beforeEach(module('template/tabs/tab.html')); - - it('should suppress warning', function() { - module(function($provide) { - $provide.value('$tabsSuppressWarning', true); - }); - - inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - var element = - '' + - '' + - 'Tab Heading One' + - '
Tab One Contents
' + - '
' + - '' + - '
Tab Two Contents
' + - '
' + - '
'; - $compile(element)($rootScope); - $rootScope.$digest(); - expect($log.warn.calls.count()).toBe(0); - }); - }); - - it('should give warning by default', inject(function($templateCache, $compile, $log, $rootScope) { - spyOn($log, 'warn'); - - var tabSetTemplate = - '
' + - '' + - '
' + - '
' + - '
' + - '
'; - $templateCache.put('template/tabs/tabset.html', tabSetTemplate); - - var tabTemplate = - '
  • ' + - '{{heading}}' + - '
  • '; - $templateCache.put('template/tabs/tab.html', tabTemplate); - - var element = - '' + - '' + - 'Tab Heading One' + - '
    Tab One Contents
    ' + - '
    ' + - '
    '; - $compile(element)($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(5); - expect($log.warn.calls.argsFor(0)).toEqual(['TabsetController is now deprecated. Use UibTabsetController instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['tab-heading-transclude is now deprecated. Use uib-tab-heading-transclude instead.']); - expect($log.warn.calls.argsFor(2)).toEqual(['tab is now deprecated. Use uib-tab instead.']); - expect($log.warn.calls.argsFor(3)).toEqual(['tabset is now deprecated. Use uib-tabset instead.']); - expect($log.warn.calls.argsFor(4)).toEqual(['tab-content-transclude is now deprecated. Use uib-tab-content-transclude instead.']); - })); -});