Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 1b75164

Browse files
committed
feat(tabs): remove deprecated code
BREAKING CHANGE: Remove deprecated directives Closes #4710
1 parent a85d499 commit 1b75164

File tree

2 files changed

+2
-224
lines changed

2 files changed

+2
-224
lines changed

src/tabs/tabs.js

+2-156
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ angular.module('ui.bootstrap.tabs', [])
238238
.directive('uibTabHeadingTransclude', function() {
239239
return {
240240
restrict: 'A',
241-
require: ['?^uibTab', '?^tab'], // TODO: change to '^uibTab' after deprecation removal
241+
require: '^uibTab',
242242
link: function(scope, elm) {
243243
scope.$watch('headingElement', function updateHeadingElement(heading) {
244244
if (heading) {
@@ -253,7 +253,7 @@ angular.module('ui.bootstrap.tabs', [])
253253
.directive('uibTabContentTransclude', function() {
254254
return {
255255
restrict: 'A',
256-
require: ['?^uibTabset', '?^tabset'], // TODO: change to '^uibTabset' after deprecation removal
256+
require: '^uibTabset',
257257
link: function(scope, elm, attrs) {
258258
var tab = scope.$eval(attrs.uibTabContentTransclude);
259259

@@ -274,166 +274,12 @@ angular.module('ui.bootstrap.tabs', [])
274274

275275
function isTabHeading(node) {
276276
return node.tagName && (
277-
node.hasAttribute('tab-heading') || // TODO: remove after deprecation removal
278-
node.hasAttribute('data-tab-heading') || // TODO: remove after deprecation removal
279-
node.hasAttribute('x-tab-heading') || // TODO: remove after deprecation removal
280277
node.hasAttribute('uib-tab-heading') ||
281278
node.hasAttribute('data-uib-tab-heading') ||
282279
node.hasAttribute('x-uib-tab-heading') ||
283-
node.tagName.toLowerCase() === 'tab-heading' || // TODO: remove after deprecation removal
284-
node.tagName.toLowerCase() === 'data-tab-heading' || // TODO: remove after deprecation removal
285-
node.tagName.toLowerCase() === 'x-tab-heading' || // TODO: remove after deprecation removal
286280
node.tagName.toLowerCase() === 'uib-tab-heading' ||
287281
node.tagName.toLowerCase() === 'data-uib-tab-heading' ||
288282
node.tagName.toLowerCase() === 'x-uib-tab-heading'
289283
);
290284
}
291285
});
292-
293-
/* deprecated tabs below */
294-
295-
angular.module('ui.bootstrap.tabs')
296-
297-
.value('$tabsSuppressWarning', false)
298-
299-
.controller('TabsetController', ['$scope', '$controller', '$log', '$tabsSuppressWarning', function($scope, $controller, $log, $tabsSuppressWarning) {
300-
if (!$tabsSuppressWarning) {
301-
$log.warn('TabsetController is now deprecated. Use UibTabsetController instead.');
302-
}
303-
304-
angular.extend(this, $controller('UibTabsetController', {
305-
$scope: $scope
306-
}));
307-
}])
308-
309-
.directive('tabset', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
310-
return {
311-
restrict: 'EA',
312-
transclude: true,
313-
replace: true,
314-
scope: {
315-
type: '@'
316-
},
317-
controller: 'TabsetController',
318-
templateUrl: 'template/tabs/tabset.html',
319-
link: function(scope, element, attrs) {
320-
321-
if (!$tabsSuppressWarning) {
322-
$log.warn('tabset is now deprecated. Use uib-tabset instead.');
323-
}
324-
scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
325-
scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
326-
}
327-
};
328-
}])
329-
330-
.directive('tab', ['$parse', '$log', '$tabsSuppressWarning', function($parse, $log, $tabsSuppressWarning) {
331-
return {
332-
require: '^tabset',
333-
restrict: 'EA',
334-
replace: true,
335-
templateUrl: 'template/tabs/tab.html',
336-
transclude: true,
337-
scope: {
338-
active: '=?',
339-
heading: '@',
340-
onSelect: '&select', //This callback is called in contentHeadingTransclude
341-
//once it inserts the tab's content into the dom
342-
onDeselect: '&deselect'
343-
},
344-
controller: function() {
345-
//Empty controller so other directives can require being 'under' a tab
346-
},
347-
link: function(scope, elm, attrs, tabsetCtrl, transclude) {
348-
if (!$tabsSuppressWarning) {
349-
$log.warn('tab is now deprecated. Use uib-tab instead.');
350-
}
351-
352-
scope.$watch('active', function(active) {
353-
if (active) {
354-
tabsetCtrl.select(scope);
355-
}
356-
});
357-
358-
scope.disabled = false;
359-
if (attrs.disable) {
360-
scope.$parent.$watch($parse(attrs.disable), function(value) {
361-
scope.disabled = !!value;
362-
});
363-
}
364-
365-
scope.select = function() {
366-
if (!scope.disabled) {
367-
scope.active = true;
368-
}
369-
};
370-
371-
tabsetCtrl.addTab(scope);
372-
scope.$on('$destroy', function() {
373-
tabsetCtrl.removeTab(scope);
374-
});
375-
376-
//We need to transclude later, once the content container is ready.
377-
//when this link happens, we're inside a tab heading.
378-
scope.$transcludeFn = transclude;
379-
}
380-
};
381-
}])
382-
383-
.directive('tabHeadingTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
384-
return {
385-
restrict: 'A',
386-
require: '^tab',
387-
link: function(scope, elm) {
388-
if (!$tabsSuppressWarning) {
389-
$log.warn('tab-heading-transclude is now deprecated. Use uib-tab-heading-transclude instead.');
390-
}
391-
392-
scope.$watch('headingElement', function updateHeadingElement(heading) {
393-
if (heading) {
394-
elm.html('');
395-
elm.append(heading);
396-
}
397-
});
398-
}
399-
};
400-
}])
401-
402-
.directive('tabContentTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
403-
return {
404-
restrict: 'A',
405-
require: '^tabset',
406-
link: function(scope, elm, attrs) {
407-
if (!$tabsSuppressWarning) {
408-
$log.warn('tab-content-transclude is now deprecated. Use uib-tab-content-transclude instead.');
409-
}
410-
411-
var tab = scope.$eval(attrs.tabContentTransclude);
412-
413-
//Now our tab is ready to be transcluded: both the tab heading area
414-
//and the tab content area are loaded. Transclude 'em both.
415-
tab.$transcludeFn(tab.$parent, function(contents) {
416-
angular.forEach(contents, function(node) {
417-
if (isTabHeading(node)) {
418-
//Let tabHeadingTransclude know.
419-
tab.headingElement = node;
420-
}
421-
else {
422-
elm.append(node);
423-
}
424-
});
425-
});
426-
}
427-
};
428-
429-
function isTabHeading(node) {
430-
return node.tagName && (
431-
node.hasAttribute('tab-heading') ||
432-
node.hasAttribute('data-tab-heading') ||
433-
node.hasAttribute('x-tab-heading') ||
434-
node.tagName.toLowerCase() === 'tab-heading' ||
435-
node.tagName.toLowerCase() === 'data-tab-heading' ||
436-
node.tagName.toLowerCase() === 'x-tab-heading'
437-
);
438-
}
439-
}]);

src/tabs/test/tabs.spec.js

-68
Original file line numberDiff line numberDiff line change
@@ -853,71 +853,3 @@ describe('tabs', function() {
853853
}));
854854
});
855855
});
856-
857-
/* deprecation tests below */
858-
859-
describe('tab deprecation', function() {
860-
beforeEach(module('ui.bootstrap.tabs'));
861-
beforeEach(module('template/tabs/tabset.html'));
862-
beforeEach(module('template/tabs/tab.html'));
863-
864-
it('should suppress warning', function() {
865-
module(function($provide) {
866-
$provide.value('$tabsSuppressWarning', true);
867-
});
868-
869-
inject(function($compile, $log, $rootScope) {
870-
spyOn($log, 'warn');
871-
872-
var element =
873-
'<tabset>' +
874-
'<tab>' +
875-
'<tab-heading>Tab Heading One</tab-heading>' +
876-
'<div>Tab One Contents</div>' +
877-
'</tab>' +
878-
'<tab heading="Tab Heading Two">' +
879-
'<div>Tab Two Contents</div>' +
880-
'</tab>' +
881-
'</tabset>';
882-
$compile(element)($rootScope);
883-
$rootScope.$digest();
884-
expect($log.warn.calls.count()).toBe(0);
885-
});
886-
});
887-
888-
it('should give warning by default', inject(function($templateCache, $compile, $log, $rootScope) {
889-
spyOn($log, 'warn');
890-
891-
var tabSetTemplate =
892-
'<div>' +
893-
'<ul class="nav nav-{{type || \'tabs\'}}" ng-class="{\'nav-stacked\': vertical, \'nav-justified\': justified}" ng-transclude></ul>' +
894-
'<div class="tab-content">' +
895-
'<div class="tab-pane" ng-repeat="tab in tabs" ng-class="{active: tab.active}" tab-content-transclude="tab"></div>' +
896-
'</div>' +
897-
'</div>';
898-
$templateCache.put('template/tabs/tabset.html', tabSetTemplate);
899-
900-
var tabTemplate =
901-
'<li ng-class="{active: active, disabled: disabled}">' +
902-
'<a href ng-click="select()" tab-heading-transclude>{{heading}}</a>' +
903-
'</li>';
904-
$templateCache.put('template/tabs/tab.html', tabTemplate);
905-
906-
var element =
907-
'<tabset>' +
908-
'<tab>' +
909-
'<tab-heading>Tab Heading One</tab-heading>' +
910-
'<div>Tab One Contents</div>' +
911-
'</tab>' +
912-
'</tabset>';
913-
$compile(element)($rootScope);
914-
$rootScope.$digest();
915-
916-
expect($log.warn.calls.count()).toBe(5);
917-
expect($log.warn.calls.argsFor(0)).toEqual(['TabsetController is now deprecated. Use UibTabsetController instead.']);
918-
expect($log.warn.calls.argsFor(1)).toEqual(['tab-heading-transclude is now deprecated. Use uib-tab-heading-transclude instead.']);
919-
expect($log.warn.calls.argsFor(2)).toEqual(['tab is now deprecated. Use uib-tab instead.']);
920-
expect($log.warn.calls.argsFor(3)).toEqual(['tabset is now deprecated. Use uib-tabset instead.']);
921-
expect($log.warn.calls.argsFor(4)).toEqual(['tab-content-transclude is now deprecated. Use uib-tab-content-transclude instead.']);
922-
}));
923-
});

0 commit comments

Comments
 (0)