mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-18 15:50:22 +00:00
chore(parseInt): cleanup parseInt() for our int()
This commit is contained in:
parent
5ac14f633a
commit
d4ae7988da
6 changed files with 10 additions and 9 deletions
|
|
@ -61,7 +61,7 @@ var $boolean = 'boolean',
|
|||
$undefined = 'undefined',
|
||||
Error = window.Error,
|
||||
/** holds major version number for IE or NaN for real browsers */
|
||||
msie = parseInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1], 10),
|
||||
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
|
||||
jqLite, // delay binding since jQuery could be loaded after us.
|
||||
jQuery, // delay binding
|
||||
slice = [].slice,
|
||||
|
|
@ -205,6 +205,10 @@ function extend(dst) {
|
|||
return dst;
|
||||
}
|
||||
|
||||
function int(str) {
|
||||
return parseInt(str, 10);
|
||||
}
|
||||
|
||||
|
||||
function inherit(parent, extra) {
|
||||
return extend(new (extend(function() {}, {prototype:parent}))(), extra);
|
||||
|
|
|
|||
|
|
@ -74,9 +74,6 @@ function jsonStringToDate(string){
|
|||
return date;
|
||||
}
|
||||
return string;
|
||||
function int(str) {
|
||||
return parseInt(str, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function jsonDateToString(date){
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ function textInputType(scope, element, attr, ctrl) {
|
|||
|
||||
// min length validator
|
||||
if (attr.ngMinlength) {
|
||||
var minlength = parseInt(attr.ngMinlength, 10);
|
||||
var minlength = int(attr.ngMinlength);
|
||||
var minLengthValidator = function(value) {
|
||||
if (!isEmpty(value) && value.length < minlength) {
|
||||
ctrl.$setValidity('minlength', false);
|
||||
|
|
@ -432,7 +432,7 @@ function textInputType(scope, element, attr, ctrl) {
|
|||
|
||||
// max length validator
|
||||
if (attr.ngMaxlength) {
|
||||
var maxlength = parseInt(attr.ngMaxlength, 10);
|
||||
var maxlength = int(attr.ngMaxlength);
|
||||
var maxLengthValidator = function(value) {
|
||||
if (!isEmpty(value) && value.length > maxlength) {
|
||||
ctrl.$setValidity('maxlength', false);
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ function dateFilter($locale) {
|
|||
format = $locale.DATETIME_FORMATS[format] || format;
|
||||
if (isString(date)) {
|
||||
if (NUMBER_STRING.test(date)) {
|
||||
date = parseInt(date, 10);
|
||||
date = int(date);
|
||||
} else {
|
||||
date = jsonStringToDate(date);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
function limitToFilter(){
|
||||
return function(array, limit) {
|
||||
if (!(array instanceof Array)) return array;
|
||||
limit = parseInt(limit, 10);
|
||||
limit = int(limit);
|
||||
var out = [],
|
||||
i, n;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ function matchUrl(url, obj) {
|
|||
match = {
|
||||
protocol: match[1],
|
||||
host: match[3],
|
||||
port: parseInt(match[5], 10) || DEFAULT_PORTS[match[1]] || null,
|
||||
port: int(match[5]) || DEFAULT_PORTS[match[1]] || null,
|
||||
path: match[6] || '/',
|
||||
search: match[8],
|
||||
hash: match[10]
|
||||
|
|
|
|||
Loading…
Reference in a new issue