Skip to content

Commit

Permalink
Core: Drop the root parameter of jQuery.fn.init
Browse files Browse the repository at this point in the history
The third parameter of `jQuery.fn.init` - `root` - was just needed to support
`jQuery.sub`. Since this API has been removed in jQuery 1.9.0 and Migrate 3.x
is not filling it in, this parameter is no longer needed.

This parameter has never been documented but it's safer to remove it in a major
update.

Closes gh-5096
  • Loading branch information
mgol committed Aug 29, 2022
1 parent 8cf39b7 commit d2436df
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/core/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ var rootjQuery,
// Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,

init = jQuery.fn.init = function( selector, context, root ) {
init = jQuery.fn.init = function( selector, context ) {
var match, elem;

// HANDLE: $(""), $(null), $(undefined), $(false)
if ( !selector ) {
return this;
}

// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;

// HANDLE: $(DOMElement)
if ( selector.nodeType ) {
this[ 0 ] = selector;
Expand All @@ -36,8 +32,8 @@ var rootjQuery,
// HANDLE: $(function)
// Shortcut for document ready
} else if ( typeof selector === "function" ) {
return root.ready !== undefined ?
root.ready( selector ) :
return rootjQuery.ready !== undefined ?
rootjQuery.ready( selector ) :

// Execute immediately if ready is not present
selector( jQuery );
Expand Down Expand Up @@ -108,7 +104,7 @@ var rootjQuery,

// HANDLE: $(expr) & $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || root ).find( selector );
return ( context || rootjQuery ).find( selector );

// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
Expand Down

0 comments on commit d2436df

Please sign in to comment.