Skip to content

Commit d3748a2

Browse files
brighton1101Brighton Balfrey
andauthored
Core: Fixes deprecated calls to jQuery trim (#2328)
Fixes #2327 Co-authored-by: Brighton Balfrey <BBalfrey@fandango.com>
1 parent 25a0f14 commit d3748a2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/core.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,25 @@ $.extend( $.fn, {
198198
}
199199
} );
200200

201+
// JQuery trim is deprecated, provide a trim method based on String.prototype.trim
202+
var trim = function( str ) {
203+
204+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill
205+
return str.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" );
206+
};
207+
201208
// Custom selectors
202209
$.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables backwards compatibility to jQuery 1.7. Can be removed when dropping jQ 1.7.x support
203210

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

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

215222
// https://jqueryvalidation.org/unchecked-selector/

0 commit comments

Comments
 (0)