From 6350f43f071a11ec6789674042ffc1fbb98d5230 Mon Sep 17 00:00:00 2001 From: Elisea Cornejo Date: Thu, 29 Apr 2021 11:00:00 +0200 Subject: [PATCH 1/8] MC-41897: Fix jQuery.fn.bind() - Change deprecated function bind and unbind --- .../Swatches/view/adminhtml/web/js/product-attributes.js | 4 ++-- app/code/Magento/Ui/view/base/web/js/grid/resize.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js index 9e48af20ee945..c4fdd7169b944 100644 --- a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js +++ b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js @@ -431,10 +431,10 @@ define([ tableBody = $(), activePanel = $(); - $('#frontend_input').bind('change', function () { + $('#frontend_input').on('change', function () { swatchProductAttributes.bindAttributeInputType(); }); - $('#is_filterable').bind('change', function () { + $('#is_filterable').on('change', function () { swatchProductAttributes.switchIsFilterable(); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/resize.js b/app/code/Magento/Ui/view/base/web/js/grid/resize.js index 792c997f060c6..b81502af8bd6e 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/resize.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/resize.js @@ -445,7 +445,7 @@ define([ cfg.depResizeElem.model.width = $(cfg.depResizeElem.elems[0]).outerWidth(); body.addClass(this.inResizeClass); body.bind('mousemove', this.mousemoveHandler); - $(window).bind('mouseup', this.mouseupHandler); + $(window).on('mouseup', this.mouseupHandler); }, /** @@ -529,7 +529,7 @@ define([ body.removeClass(this.inResizeClass); body.unbind('mousemove', this.mousemoveHandler); - $(window).unbind('mouseup', this.mouseupHandler); + $(window).off('mouseup', this.mouseupHandler); }, /** From 227f98840cefa59b0b4fd153082155d0bf646288 Mon Sep 17 00:00:00 2001 From: Marc Ginesta Date: Tue, 4 May 2021 12:44:49 +0200 Subject: [PATCH 2/8] Revert "MC-40693: Upgrade to the latest JQuery 3.6.x" This reverts commit 6d15f74c406940976c11f81c74763336f2d26dda. --- lib/web/jquery/jquery-migrate.js | 1580 ++++++++++++++---------------- 1 file changed, 737 insertions(+), 843 deletions(-) diff --git a/lib/web/jquery/jquery-migrate.js b/lib/web/jquery/jquery-migrate.js index d07a7487d45e0..d5ce9187d5bb5 100644 --- a/lib/web/jquery/jquery-migrate.js +++ b/lib/web/jquery/jquery-migrate.js @@ -1,859 +1,753 @@ /*! - * jQuery Migrate - v3.3.2 - 2020-11-17T23:22Z - * Copyright OpenJS Foundation and other contributors + * jQuery Migrate - v1.4.1 - 2016-05-19 + * Copyright jQuery Foundation and other contributors */ -( function( factory ) { - "use strict"; - - if ( typeof define === "function" && define.amd ) { - - // AMD. Register as an anonymous module. - define( [ "jquery" ], function( jQuery ) { - return factory( jQuery, window ); - } ); - } else if ( typeof module === "object" && module.exports ) { - - // Node/CommonJS - // eslint-disable-next-line no-undef - module.exports = factory( require( "jquery" ), window ); - } else { - - // Browser globals - factory( jQuery, window ); - } -} )( function( jQuery, window ) { - "use strict"; - - jQuery.migrateVersion = "3.3.2"; - -// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2 - function compareVersions( v1, v2 ) { - var i, - rVersionParts = /^(\d+)\.(\d+)\.(\d+)/, - v1p = rVersionParts.exec( v1 ) || [ ], - v2p = rVersionParts.exec( v2 ) || [ ]; - - for ( i = 1; i <= 3; i++ ) { - if ( +v1p[ i ] > +v2p[ i ] ) { - return 1; - } - if ( +v1p[ i ] < +v2p[ i ] ) { - return -1; - } - } - return 0; - } - - function jQueryVersionSince( version ) { - return compareVersions( jQuery.fn.jquery, version ) >= 0; - } - - ( function() { - - // Support: IE9 only - // IE9 only creates console object when dev tools are first opened - // IE9 console is a host object, callable but doesn't have .apply() - if ( !window.console || !window.console.log ) { - return; - } - - // Need jQuery 3.0.0+ and no older Migrate loaded - if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) { - window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" ); - } - if ( jQuery.migrateWarnings ) { - window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); - } - - // Show a message on the console so devs know we're active - window.console.log( "JQMIGRATE: Migrate is installed" + - ( jQuery.migrateMute ? "" : " with logging active" ) + - ", version " + jQuery.migrateVersion ); - - } )(); - - var warnedAbout = {}; - -// By default each warning is only reported once. - jQuery.migrateDeduplicateWarnings = true; +(function( jQuery, window, undefined ) { +// See http://bugs.jquery.com/ticket/13335 +// "use strict"; + + +jQuery.migrateVersion = "1.4.1"; + + +var warnedAbout = {}; // List of warnings already given; public read only - jQuery.migrateWarnings = []; +jQuery.migrateWarnings = []; + +// Set to true to prevent console output; migrateWarnings still maintained +// jQuery.migrateMute = false; + +// Show a message on the console so devs know we're active +if ( window.console && window.console.log ) { + window.console.log( "JQMIGRATE: Migrate is installed" + + ( jQuery.migrateMute ? "" : " with logging active" ) + + ", version " + jQuery.migrateVersion ); +} // Set to false to disable traces that appear with warnings - if ( jQuery.migrateTrace === undefined ) { - jQuery.migrateTrace = true; - } +if ( jQuery.migrateTrace === undefined ) { + jQuery.migrateTrace = true; +} // Forget any warnings we've already given; public - jQuery.migrateReset = function() { - warnedAbout = {}; - jQuery.migrateWarnings.length = 0; - }; - - function migrateWarn( msg ) { - var console = window.console; - if ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) { - warnedAbout[ msg ] = true; - jQuery.migrateWarnings.push( msg ); - if ( console && console.warn && !jQuery.migrateMute ) { - console.warn( "JQMIGRATE: " + msg ); - if ( jQuery.migrateTrace && console.trace ) { - console.trace(); - } - } - } - } - - function migrateWarnProp( obj, prop, value, msg ) { - Object.defineProperty( obj, prop, { - configurable: true, - enumerable: true, - get: function() { - migrateWarn( msg ); - return value; - }, - set: function( newValue ) { - migrateWarn( msg ); - value = newValue; - } - } ); - } - - function migrateWarnFunc( obj, prop, newFunc, msg ) { - obj[ prop ] = function() { - migrateWarn( msg ); - return newFunc.apply( this, arguments ); - }; - } - - if ( window.document.compatMode === "BackCompat" ) { - - // JQuery has never supported or tested Quirks Mode - migrateWarn( "jQuery is not compatible with Quirks Mode" ); - } - - var findProp, - class2type = {}, - oldInit = jQuery.fn.init, - oldFind = jQuery.find, - - rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, - rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, - - // Support: Android <=4.0 only - // Make sure we trim BOM and NBSP - rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; - - jQuery.fn.init = function( arg1 ) { - var args = Array.prototype.slice.call( arguments ); - - if ( typeof arg1 === "string" && arg1 === "#" ) { - - // JQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0 - migrateWarn( "jQuery( '#' ) is not a valid selector" ); - args[ 0 ] = []; - } - - return oldInit.apply( this, args ); - }; - jQuery.fn.init.prototype = jQuery.fn; - - jQuery.find = function( selector ) { - var args = Array.prototype.slice.call( arguments ); - - // Support: PhantomJS 1.x - // String#match fails to match when used with a //g RegExp, only on some strings - if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { - - // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 - // First see if qS thinks it's a valid selector, if so avoid a false positive - try { - window.document.querySelector( selector ); - } catch ( err1 ) { - - // Didn't *look* valid to qSA, warn and try quoting what we think is the value - selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { - return "[" + attr + op + "\"" + value + "\"]"; - } ); - - // If the regexp *may* have created an invalid selector, don't update it - // Note that there may be false alarms if selector uses jQuery extensions - try { - window.document.querySelector( selector ); - migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] ); - args[ 0 ] = selector; - } catch ( err2 ) { - migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] ); - } - } - } - - return oldFind.apply( this, args ); - }; +jQuery.migrateReset = function() { + warnedAbout = {}; + jQuery.migrateWarnings.length = 0; +}; + +function migrateWarn( msg) { + var console = window.console; + if ( !warnedAbout[ msg ] ) { + warnedAbout[ msg ] = true; + jQuery.migrateWarnings.push( msg ); + if ( console && console.warn && !jQuery.migrateMute ) { + console.warn( "JQMIGRATE: " + msg ); + if ( jQuery.migrateTrace && console.trace ) { + console.trace(); + } + } + } +} + +function migrateWarnProp( obj, prop, value, msg ) { + if ( Object.defineProperty ) { + // On ES5 browsers (non-oldIE), warn if the code tries to get prop; + // allow property to be overwritten in case some other plugin wants it + try { + Object.defineProperty( obj, prop, { + configurable: true, + enumerable: true, + get: function() { + migrateWarn( msg ); + return value; + }, + set: function( newValue ) { + migrateWarn( msg ); + value = newValue; + } + }); + return; + } catch( err ) { + // IE8 is a dope about Object.defineProperty, can't warn there + } + } + + // Non-ES5 (or broken) browser; just set the property + jQuery._definePropertyBroken = true; + obj[ prop ] = value; +} + +if ( document.compatMode === "BackCompat" ) { + // jQuery has never supported or tested Quirks Mode + migrateWarn( "jQuery is not compatible with Quirks Mode" ); +} + + +var attrFn = jQuery( "", { size: 1 } ).attr("size") && jQuery.attrFn, + oldAttr = jQuery.attr, + valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || + function() { return null; }, + valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || + function() { return undefined; }, + rnoType = /^(?:input|button)$/i, + rnoAttrNodeType = /^[238]$/, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + ruseDefault = /^(?:checked|selected)$/i; + +// jQuery.attrFn +migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); + +jQuery.attr = function( elem, name, value, pass ) { + var lowerName = name.toLowerCase(), + nType = elem && elem.nodeType; + + if ( pass ) { + // Since pass is used internally, we only warn for new jQuery + // versions where there isn't a pass arg in the formal params + if ( oldAttr.length < 4 ) { + migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); + } + if ( elem && !rnoAttrNodeType.test( nType ) && + (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { + return jQuery( elem )[ name ]( value ); + } + } + + // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking + // for disconnected elements we don't warn on $( "