Skip to content

Commit

Permalink
Core: Fixes deprecated calls to jQuery trim (#2328)
Browse files Browse the repository at this point in the history
Fixes #2327

Co-authored-by: Brighton Balfrey <BBalfrey@fandango.com>
  • Loading branch information
brighton1101 and Brighton Balfrey committed May 13, 2020
1 parent 25a0f14 commit d3748a2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core.js
Expand Up @@ -198,18 +198,25 @@ $.extend( $.fn, {
}
} );

// JQuery trim is deprecated, provide a trim method based on String.prototype.trim
var trim = function( str ) {

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill
return str.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" );
};

// Custom selectors
$.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables backwards compatibility to jQuery 1.7. Can be removed when dropping jQ 1.7.x support

// https://jqueryvalidation.org/blank-selector/
blank: function( a ) {
return !$.trim( "" + $( a ).val() );
return !trim( "" + $( a ).val() );
},

// https://jqueryvalidation.org/filled-selector/
filled: function( a ) {
var val = $( a ).val();
return val !== null && !!$.trim( "" + val );
return val !== null && !!trim( "" + val );
},

// https://jqueryvalidation.org/unchecked-selector/
Expand Down

0 comments on commit d3748a2

Please sign in to comment.