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

Commit d844623

Browse files
Foxandxsswesleycho
authored andcommitted
feat(rating): remove deprecated code
BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4723
1 parent 1b75164 commit d844623

File tree

2 files changed

+5
-76
lines changed

2 files changed

+5
-76
lines changed

src/rating/rating.js

-38
Original file line numberDiff line numberDiff line change
@@ -97,41 +97,3 @@ angular.module('ui.bootstrap.rating', [])
9797
}
9898
};
9999
});
100-
101-
/* Deprecated rating below */
102-
103-
angular.module('ui.bootstrap.rating')
104-
105-
.value('$ratingSuppressWarning', false)
106-
107-
.controller('RatingController', ['$scope', '$attrs', '$controller', '$log', '$ratingSuppressWarning', function($scope, $attrs, $controller, $log, $ratingSuppressWarning) {
108-
if (!$ratingSuppressWarning) {
109-
$log.warn('RatingController is now deprecated. Use UibRatingController instead.');
110-
}
111-
112-
angular.extend(this, $controller('UibRatingController', {
113-
$scope: $scope,
114-
$attrs: $attrs
115-
}));
116-
}])
117-
118-
.directive('rating', ['$log', '$ratingSuppressWarning', function($log, $ratingSuppressWarning) {
119-
return {
120-
require: ['rating', 'ngModel'],
121-
scope: {
122-
readonly: '=?',
123-
onHover: '&',
124-
onLeave: '&'
125-
},
126-
controller: 'RatingController',
127-
templateUrl: 'template/rating/rating.html',
128-
replace: true,
129-
link: function(scope, element, attrs, ctrls) {
130-
if (!$ratingSuppressWarning) {
131-
$log.warn('rating is now deprecated. Use uib-rating instead.');
132-
}
133-
var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];
134-
ratingCtrl.init(ngModelCtrl);
135-
}
136-
};
137-
}]);

src/rating/test/rating.spec.js

+5-38
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('rating directive', function() {
3333
return angular.element(star).attr('title');
3434
});
3535
}
36-
36+
3737
function triggerKeyDown(keyCode) {
3838
var e = $.Event('keydown');
3939
e.which = keyCode;
@@ -280,13 +280,13 @@ describe('rating directive', function() {
280280
expect(getState('on', 'off')).toEqual([true, true, true, true, true, false, false, false, false, false]);
281281
});
282282
});
283-
283+
284284
describe('Default title', function() {
285285
it('should return the default title for each star', function() {
286286
expect(getTitles()).toEqual(['one', 'two', 'three', 'four', 'five']);
287287
});
288288
});
289-
289+
290290
describe('shows different title when `max` attribute is greater than the titles array ', function() {
291291
var originalConfig = {};
292292
beforeEach(inject(function(uibRatingConfig) {
@@ -300,12 +300,12 @@ describe('rating directive', function() {
300300
// return it to the original state
301301
angular.extend(uibRatingConfig, originalConfig);
302302
}));
303-
303+
304304
it('should return the default title for each star', function() {
305305
expect(getTitles()).toEqual(['one', 'two', 'three', 'four', 'five', '6', '7', '8', '9', '10']);
306306
});
307307
});
308-
308+
309309
describe('shows custom titles ', function() {
310310
it('should return the custom title for each star', function() {
311311
$rootScope.titles = [44,45,46];
@@ -326,36 +326,3 @@ describe('rating directive', function() {
326326
});
327327
});
328328
});
329-
330-
/* Deprecation tests below */
331-
332-
describe('rating deprecation', function() {
333-
beforeEach(module('ui.bootstrap.rating'));
334-
beforeEach(module('template/rating/rating.html'));
335-
336-
it('should suppress warning', function() {
337-
module(function($provide) {
338-
$provide.value('$ratingSuppressWarning', true);
339-
});
340-
341-
inject(function($compile, $log, $rootScope) {
342-
spyOn($log, 'warn');
343-
344-
var element = $compile('<rating ng-model="rate"></rating>')($rootScope);
345-
$rootScope.$digest();
346-
347-
expect($log.warn.calls.count()).toBe(0);
348-
});
349-
});
350-
351-
it('should give warning by default', inject(function($compile, $log, $rootScope) {
352-
spyOn($log, 'warn');
353-
354-
var element = $compile('<rating ng-model="rate"></rating>')($rootScope);
355-
$rootScope.$digest();
356-
357-
expect($log.warn.calls.count()).toBe(2);
358-
expect($log.warn.calls.argsFor(0)).toEqual(['RatingController is now deprecated. Use UibRatingController instead.']);
359-
expect($log.warn.calls.argsFor(1)).toEqual(['rating is now deprecated. Use uib-rating instead.']);
360-
}));
361-
});

0 commit comments

Comments
 (0)