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

Commit b159b21

Browse files
Foxandxsswesleycho
authored andcommitted
feat(carousel): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4717
1 parent b549263 commit b159b21

File tree

2 files changed

+1
-130
lines changed

2 files changed

+1
-130
lines changed

src/carousel/carousel.js

-74
Original file line numberDiff line numberDiff line change
@@ -420,77 +420,3 @@ function ($injector, $animate) {
420420
}
421421
};
422422
}]);
423-
424-
/* deprecated carousel below */
425-
426-
angular.module('ui.bootstrap.carousel')
427-
428-
.value('$carouselSuppressWarning', false)
429-
430-
.controller('CarouselController', ['$scope', '$element', '$controller', '$log', '$carouselSuppressWarning', function($scope, $element, $controller, $log, $carouselSuppressWarning) {
431-
if (!$carouselSuppressWarning) {
432-
$log.warn('CarouselController is now deprecated. Use UibCarouselController instead.');
433-
}
434-
435-
angular.extend(this, $controller('UibCarouselController', {
436-
$scope: $scope,
437-
$element: $element
438-
}));
439-
}])
440-
441-
.directive('carousel', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
442-
return {
443-
transclude: true,
444-
replace: true,
445-
controller: 'CarouselController',
446-
controllerAs: 'carousel',
447-
require: 'carousel',
448-
templateUrl: function(element, attrs) {
449-
return attrs.templateUrl || 'template/carousel/carousel.html';
450-
},
451-
scope: {
452-
interval: '=',
453-
noTransition: '=',
454-
noPause: '=',
455-
noWrap: '&'
456-
},
457-
link: function() {
458-
if (!$carouselSuppressWarning) {
459-
$log.warn('carousel is now deprecated. Use uib-carousel instead.');
460-
}
461-
}
462-
};
463-
}])
464-
465-
.directive('slide', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
466-
return {
467-
require: '^carousel',
468-
transclude: true,
469-
replace: true,
470-
templateUrl: function(element, attrs) {
471-
return attrs.templateUrl || 'template/carousel/slide.html';
472-
},
473-
scope: {
474-
active: '=?',
475-
actual: '=?',
476-
index: '=?'
477-
},
478-
link: function (scope, element, attrs, carouselCtrl) {
479-
if (!$carouselSuppressWarning) {
480-
$log.warn('slide is now deprecated. Use uib-slide instead.');
481-
}
482-
483-
carouselCtrl.addSlide(scope, element);
484-
//when the scope is destroyed then remove the slide from the current slides array
485-
scope.$on('$destroy', function() {
486-
carouselCtrl.removeSlide(scope);
487-
});
488-
489-
scope.$watch('active', function(active) {
490-
if (active) {
491-
carouselCtrl.select(scope);
492-
}
493-
});
494-
}
495-
};
496-
}]);

src/carousel/test/carousel.spec.js

+1-56
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('carousel', function() {
6868

6969
elm = $compile(
7070
'<uib-carousel interval="interval" no-transition="true" no-pause="nopause">' +
71-
'<uib-slide template-url="foo/bar.html"></uib-slide>' +
71+
'<uib-slide template-url="foo/bar.html"></uib-slide>' +
7272
'</uib-carousel>'
7373
)(scope);
7474
$rootScope.$digest();
@@ -537,58 +537,3 @@ describe('carousel', function() {
537537
}), scope.slides)).toBe(true);
538538
});
539539
});
540-
541-
describe('carousel deprecation', function() {
542-
beforeEach(module('ui.bootstrap.carousel'));
543-
beforeEach(module('template/carousel/carousel.html', 'template/carousel/slide.html'));
544-
545-
it('should suppress warning', function() {
546-
module(function($provide) {
547-
$provide.value('$carouselSuppressWarning', true);
548-
});
549-
550-
inject(function($compile, $log, $rootScope) {
551-
spyOn($log, 'warn');
552-
553-
var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
554-
'<slide ng-repeat="slide in slides" active="slide.active">' +
555-
'{{slide.content}}' +
556-
'</slide>' +
557-
'</carousel>';
558-
element = $compile(element)($rootScope);
559-
$rootScope.$digest();
560-
expect($log.warn.calls.count()).toBe(0);
561-
});
562-
});
563-
564-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
565-
spyOn($log, 'warn');
566-
567-
var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
568-
'<slide ng-repeat="slide in slides" active="slide.active">' +
569-
'{{slide.content}}' +
570-
'</slide>' +
571-
'</carousel>';
572-
element = $compile(element)($rootScope);
573-
$rootScope.$digest();
574-
575-
expect($log.warn.calls.count()).toBe(2);
576-
expect($log.warn.calls.argsFor(0)).toEqual(['CarouselController is now deprecated. Use UibCarouselController instead.']);
577-
expect($log.warn.calls.argsFor(1)).toEqual(['carousel is now deprecated. Use uib-carousel instead.']);
578-
}));
579-
580-
it('should give warning by default for slider', inject(function($compile, $log, $rootScope) {
581-
spyOn($log, 'warn');
582-
583-
var element = '<carousel interval="interval" no-transition="true" no-pause="nopause">' +
584-
'<slide></slide>' +
585-
'</carousel>';
586-
element = $compile(element)($rootScope);
587-
$rootScope.$digest();
588-
589-
expect($log.warn.calls.count()).toBe(3);
590-
expect($log.warn.calls.argsFor(0)).toEqual(['CarouselController is now deprecated. Use UibCarouselController instead.']);
591-
expect($log.warn.calls.argsFor(1)).toEqual(['slide is now deprecated. Use uib-slide instead.']);
592-
expect($log.warn.calls.argsFor(2)).toEqual(['carousel is now deprecated. Use uib-carousel instead.']);
593-
}));
594-
});

0 commit comments

Comments
 (0)