Skip to content

Commit d322192

Browse files
committed
fix(timepicker): Don't allow mixture of numbers and letters.
Closes angular-ui#5085
1 parent aa010b0 commit d322192

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Diff for: src/timepicker/test/timepicker.spec.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,6 @@ describe('timepicker directive', function() {
11591159
expect(getModelState()).toEqual([14, 9, 25]);
11601160
});
11611161

1162-
11631162
it('updates seconds & pads on input change & pads on blur', function() {
11641163
var el = getSecondsInputEl();
11651164

@@ -1192,7 +1191,7 @@ describe('timepicker directive', function() {
11921191
it('clears model when input minutes is invalid & alerts the UI', function() {
11931192
var el = getMinutesInputEl();
11941193

1195-
changeInputValueTo(el, 'pizza');
1194+
changeInputValueTo(el, '8a');
11961195
expect($rootScope.time).toBe(null);
11971196
expect(el.parent().hasClass('has-error')).toBe(true);
11981197
expect(element.hasClass('ng-invalid-time')).toBe(true);
@@ -1204,7 +1203,6 @@ describe('timepicker directive', function() {
12041203
expect(element.hasClass('ng-invalid-time')).toBe(false);
12051204
});
12061205

1207-
12081206
it('clears model when input seconds is invalid & alerts the UI', function() {
12091207
var el = getSecondsInputEl();
12101208

Diff for: src/timepicker/timepicker.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ angular.module('ui.bootstrap.timepicker', [])
5151
var hourStep = timepickerConfig.hourStep;
5252
if ($attrs.hourStep) {
5353
$scope.$parent.$watch($parse($attrs.hourStep), function(value) {
54-
hourStep = parseInt(value, 10);
54+
hourStep = Number(value);
5555
});
5656
}
5757

5858
var minuteStep = timepickerConfig.minuteStep;
5959
if ($attrs.minuteStep) {
6060
$scope.$parent.$watch($parse($attrs.minuteStep), function(value) {
61-
minuteStep = parseInt(value, 10);
61+
minuteStep = Number(value);
6262
});
6363
}
6464

@@ -128,7 +128,7 @@ angular.module('ui.bootstrap.timepicker', [])
128128
var secondStep = timepickerConfig.secondStep;
129129
if ($attrs.secondStep) {
130130
$scope.$parent.$watch($parse($attrs.secondStep), function(value) {
131-
secondStep = parseInt(value, 10);
131+
secondStep = Number(value);
132132
});
133133
}
134134

@@ -160,7 +160,7 @@ angular.module('ui.bootstrap.timepicker', [])
160160

161161
// Get $scope.hours in 24H mode if valid
162162
function getHoursFromTemplate() {
163-
var hours = parseInt($scope.hours, 10);
163+
var hours = Number($scope.hours);
164164
var valid = $scope.showMeridian ? hours > 0 && hours < 13 :
165165
hours >= 0 && hours < 24;
166166
if (!valid) {
@@ -179,12 +179,12 @@ angular.module('ui.bootstrap.timepicker', [])
179179
}
180180

181181
function getMinutesFromTemplate() {
182-
var minutes = parseInt($scope.minutes, 10);
182+
var minutes = Number($scope.minutes);
183183
return minutes >= 0 && minutes < 60 ? minutes : undefined;
184184
}
185185

186186
function getSecondsFromTemplate() {
187-
var seconds = parseInt($scope.seconds, 10);
187+
var seconds = Number($scope.seconds);
188188
return seconds >= 0 && seconds < 60 ? seconds : undefined;
189189
}
190190

0 commit comments

Comments
 (0)