From fb6c9911e8ee5a84adf649aae4d725c8695aa2e0 Mon Sep 17 00:00:00 2001 From: Brighton Balfrey Date: Thu, 7 May 2020 10:41:46 -0700 Subject: [PATCH 1/3] Core: Fixes deprecated calls to jQuery trim. Fixes #2327 --- src/core.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index ccb8d4cbe..a0ff7d0c1 100644 --- a/src/core.js +++ b/src/core.js @@ -1,3 +1,12 @@ +// JQuery trim is deprecated, polyfill native js method if not defined +if ( !String.prototype.trim ) { + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill + String.prototype.trim = function() { + return this.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" ); + }; +} + $.extend( $.fn, { // https://jqueryvalidation.org/validate/ @@ -203,13 +212,13 @@ $.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables // https://jqueryvalidation.org/blank-selector/ blank: function( a ) { - return !$.trim( "" + $( a ).val() ); + return !( "" + $( a ).val() ).trim(); }, // https://jqueryvalidation.org/filled-selector/ filled: function( a ) { var val = $( a ).val(); - return val !== null && !!$.trim( "" + val ); + return val !== null && !!( "" + val ).trim(); }, // https://jqueryvalidation.org/unchecked-selector/ From 540bcaeba36bf652d5daeb5d0227b15fbc99793d Mon Sep 17 00:00:00 2001 From: Brighton Balfrey Date: Thu, 7 May 2020 11:28:27 -0700 Subject: [PATCH 2/3] Core: Adds on trim method w/o overwriting native trim. Fixes #2327 --- src/core.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/core.js b/src/core.js index a0ff7d0c1..ef6fe327d 100644 --- a/src/core.js +++ b/src/core.js @@ -1,10 +1,8 @@ -// JQuery trim is deprecated, polyfill native js method if not defined -if ( !String.prototype.trim ) { +// JQuery trim is deprecated, provide a trim method based on String.prototype.trim +function trim( str ) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim#Polyfill - String.prototype.trim = function() { - return this.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" ); - }; + return str.replace( /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "" ); } $.extend( $.fn, { @@ -212,13 +210,13 @@ $.extend( $.expr.pseudos || $.expr[ ":" ], { // '|| $.expr[ ":" ]' here enables // https://jqueryvalidation.org/blank-selector/ blank: function( a ) { - return !( "" + $( a ).val() ).trim(); + return !trim( "" + $( a ).val() ); }, // https://jqueryvalidation.org/filled-selector/ filled: function( a ) { var val = $( a ).val(); - return val !== null && !!( "" + val ).trim(); + return val !== null && !!trim( "" + val ); }, // https://jqueryvalidation.org/unchecked-selector/ From f1e2d6f4538e89f13e844e12773731079d84847c Mon Sep 17 00:00:00 2001 From: Brighton Balfrey Date: Thu, 7 May 2020 11:54:42 -0700 Subject: [PATCH 3/3] Core: Trim method added and moved down to where needed. Fixes #2327 --- src/core.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core.js b/src/core.js index ef6fe327d..b7b8f3b9b 100644 --- a/src/core.js +++ b/src/core.js @@ -1,10 +1,3 @@ -// JQuery trim is deprecated, provide a trim method based on String.prototype.trim -function trim( 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, "" ); -} - $.extend( $.fn, { // https://jqueryvalidation.org/validate/ @@ -205,6 +198,13 @@ $.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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy