10000 Core: Remove support for jQuery 4.x by mgol · Pull Request #554 · jquery/jquery-migrate · GitHub
[go: up one dir, main page]

Skip to content

Core: Remove support for jQuery 4.x #554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 18, 2025
Prev Previous commit
Next Next commit
Core: Don't reimplement deprecated but not removed APIs
This will save space and avoid potential divergence from Core.

To minimize risk, this only handles APIs still present in jQuery 4.x.
  • Loading branch information
mgol committed Feb 2, 2025
commit 8d20816194c6c5b1ff4c8eb82c25f652bf3db873
35 changes: 3 additions & 32 deletions src/jquery/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { jQueryVersionSince } from "../compareVersions.js";
import { migratePatchAndWarnFunc } from "../main.js";
import "../disablePatches.js";

var arr = [],
slice = arr.slice,
class2type = {},
var class2type = {},

// Require that the "whitespace run" starts from a non-whitespace
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
Expand Down Expand Up @@ -116,34 +114,7 @@ if ( jQueryVersionSince( "3.3.0" ) ) {
// arguments.
// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
// However, it is not slated for removal any time soon
migratePatchAndWarnFunc( jQuery, "proxy",
function( fn, context ) {
var tmp, args, proxy;

if ( typeof context === "string" ) {
tmp = fn[ context ];
context = fn;
fn = tmp;
}

// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( !isFunction( fn ) ) {
return undefined;
}

// Simulated bind
args = slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
};

// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || jQuery.guid++;

return proxy;
}, "proxy",
"jQuery.proxy() is deprecated"
);
migratePatchAndWarnFunc( jQuery, "proxy", jQuery.proxy,
"proxy", "DEPRECATED: jQuery.proxy()" );

}
33 changes: 12 additions & 21 deletions src/jquery/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,9 @@ jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
function( _i, name ) {

// Handle event binding
migratePatchAndWarnFunc( jQuery.fn, name, function( data, fn ) {
return arguments.length > 0 ?
this.on( name, null, data, fn ) :
this.trigger( name );
},
"shorthand-deprecated-v3",
"jQuery.fn." + name + "() event shorthand is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, name, jQuery.fn[ name ], "shorthand-deprecated-v3",
"DEPRECATED: jQuery.fn." + name + "() event shorthand" );

} );

// Trigger "ready" event only once, on document ready
Expand All @@ -118,20 +114,15 @@ jQuery.event.special.ready = {
}
};

migratePatchAndWarnFunc( jQuery.fn, "bind", function( types, data, fn ) {
return this.on( types, null, data, fn );
}, "pre-on-methods", "jQuery.fn.bind() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "unbind", function( types, fn ) {
return this.off( types, null, fn );
}, "pre-on-methods", "jQuery.fn.unbind() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "delegate", function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
}, "pre-on-methods", "jQuery.fn.delegate() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "undelegate", function( selector, types, fn ) {
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
}, "pre-on-methods", "jQuery.fn.undelegate() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "bind", jQuery.fn.bind,
"pre-on-methods", "jQuery.fn.bind() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "unbind", jQuery.fn.unbind,
"pre-on-methods", "jQuery.fn.unbind() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "delegate", jQuery.fn.delegate,
"pre-on-methods", "jQuery.fn.delegate() is deprecated" );
migratePatchAndWarnFunc( jQuery.fn, "undelegate", jQuery.fn.undelegate,
"pre-on-methods", "jQuery.fn.undelegate() is deprecated" );

migratePatchAndWarnFunc( jQuery.fn, "hover", function( fnOver, fnOut ) {
return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver );
}, "pre-on-methods", "jQuery.fn.hover() is deprecated" );
0