Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Rename int() to toInt() - issue #1304 #7768

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Angular.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ var /** holds major version number for IE or NaN for real browsers */
* IE 11 changed the format of the UserAgent string.
* See http://msdn.microsoft.com/en-us/library/ms537503.aspx
*/
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
msie = toInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
if (isNaN(msie)) {
msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
msie = toInt((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);
}


Expand Down Expand Up @@ -357,7 +357,7 @@ function extend(dst) {
return dst;
}

function int(str) {
function toInt(str) {
return parseInt(str, 10);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ng/directive/input.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {

// min length validator
if (attr.ngMinlength) {
var minlength = int(attr.ngMinlength);
var minlength = toInt(attr.ngMinlength);
var minLengthValidator = function(value) {
return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length >= minlength, value);
};
Expand All @@ -1015,7 +1015,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {

// max length validator
if (attr.ngMaxlength) {
var maxlength = int(attr.ngMaxlength);
var maxlength = toInt(attr.ngMaxlength);
var maxLengthValidator = function(value) {
return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length <= maxlength, value);
};
Expand Down
14 changes: 7 additions & 7 deletions src/ng/filter/filters.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,13 @@ function dateFilter($locale) {
timeSetter = match[8] ? date.setUTCHours : date.setHours;

if (match[9]) {
tzHour = int(match[9] + match[10]);
tzMin = int(match[9] + match[11]);
tzHour = toInt(match[9] + match[10]);
tzMin = toInt(match[9] + match[11]);
}
dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
var h = int(match[4]||0) - tzHour;
var m = int(match[5]||0) - tzMin;
var s = int(match[6]||0);
dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
var h = toInt(match[4]||0) - tzHour;
var m = toInt(match[5]||0) - tzMin;
var s = toInt(match[6]||0);
var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000);
timeSetter.call(date, h, m, s, ms);
return date;
Expand All @@ -420,7 +420,7 @@ function dateFilter($locale) {
format = $locale.DATETIME_FORMATS[format] || format;
if (isString(date)) {
if (NUMBER_STRING.test(date)) {
date = int(date);
date = toInt(date);
} else {
date = jsonStringToDate(date);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ng/filter/limitTo.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function limitToFilter(){
if (Math.abs(Number(limit)) === Infinity) {
limit = Number(limit);
} else {
limit = int(limit);
limit = toInt(limit);
}

if (isString(input)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ng/location.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function parseAbsoluteUrl(absoluteUrl, locationObj, appBase) {

locationObj.$$protocol = parsedUrl.protocol;
locationObj.$$host = parsedUrl.hostname;
locationObj.$$port = int(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
locationObj.$$port = toInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
}


Expand Down
2 changes: 1 addition & 1 deletion src/ng/sniffer.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function $SnifferProvider() {
this.$get = ['$window', '$document', function($window, $document) {
var eventSupport = {},
android =
int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
document = $document[0] || {},
documentMode = document.documentMode,
Expand Down
16 changes: 8 additions & 8 deletions src/ngMock/angular-mocks.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -559,20 +559,20 @@ function jsonStringToDate(string) {
tzHour = 0,
tzMin = 0;
if (match[9]) {
tzHour = int(match[9] + match[10]);
tzMin = int(match[9] + match[11]);
tzHour = toInt(match[9] + match[10]);
tzMin = toInt(match[9] + match[11]);
}
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
date.setUTCHours(int(match[4]||0) - tzHour,
int(match[5]||0) - tzMin,
int(match[6]||0),
int(match[7]||0));
date.setUTCFullYear(toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
date.setUTCHours(toInt(match[4]||0) - tzHour,
toInt(match[5]||0) - tzMin,
toInt(match[6]||0),
toInt(match[7]||0));
return date;
}
return string;
}

function int(str) {
function toInt(str) {
return parseInt(str, 10);
}

Expand Down
4 changes: 2 additions & 2 deletions test/ng/directive/inputSpec.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ describe('input', function() {
var value = 0;
compileInput('<input type="text" ng-model="value" ng-minlength="min" attr-capture />');
attrs.$observe('minlength', function(v) {
value = int(attrs.minlength);
value = toInt(attrs.minlength);
});

scope.$apply(function() {
Expand Down Expand Up @@ -1193,7 +1193,7 @@ describe('input', function() {
var value = 0;
compileInput('<input type="text" ng-model="value" ng-maxlength="max" attr-capture />');
attrs.$observe('maxlength', function(v) {
value = int(attrs.maxlength);
value = toInt(attrs.maxlength);
});

scope.$apply(function() {
Expand Down