Skip to content

Commit

Permalink
Core: Replaced deprecated jQuery functions
Browse files Browse the repository at this point in the history
Replaced $.isArray and $.isFunction
  • Loading branch information
bytestream authored and Arkni committed Jun 24, 2020
1 parent af445b3 commit 79bed39
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core.js
Expand Up @@ -1313,7 +1313,7 @@ $.extend( $.validator, {

// Evaluate parameters
$.each( rules, function( rule, parameter ) {
rules[ rule ] = $.isFunction( parameter ) && rule !== "normalizer" ? parameter( element ) : parameter;
rules[ rule ] = typeof parameter === "function" && rule !== "normalizer" ? parameter( element ) : parameter;
} );

// Clean number parameters
Expand All @@ -1325,7 +1325,7 @@ $.extend( $.validator, {
$.each( [ "rangelength", "range" ], function() {
var parts;
if ( rules[ this ] ) {
if ( $.isArray( rules[ this ] ) ) {
if ( Array.isArray( rules[ this ] ) ) {
rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ];
} else if ( typeof rules[ this ] === "string" ) {
parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ );
Expand Down Expand Up @@ -1454,19 +1454,19 @@ $.extend( $.validator, {

// https://jqueryvalidation.org/minlength-method/
minlength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || length >= param;
},

// https://jqueryvalidation.org/maxlength-method/
maxlength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || length <= param;
},

// https://jqueryvalidation.org/rangelength-method/
rangelength: function( value, element, param ) {
var length = $.isArray( value ) ? value.length : this.getLength( value, element );
var length = Array.isArray( value ) ? value.length : this.getLength( value, element );
return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] );
},

Expand Down

0 comments on commit 79bed39

Please sign in to comment.