Commit c916aef8 authored by Timmy Willison's avatar Timmy Willison

Core: allow init to accept an alternate rootjQuery for migrate's sake

- This will be tested in migrate

Fixes gh-2101
parent cf16f860
...@@ -17,7 +17,7 @@ var rootjQuery, ...@@ -17,7 +17,7 @@ var rootjQuery,
// Shortcut simple #id case for speed // Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context ) { init = jQuery.fn.init = function( selector, context, root ) {
var match, elem; var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false) // HANDLE: $(""), $(null), $(undefined), $(false)
...@@ -25,6 +25,10 @@ var rootjQuery, ...@@ -25,6 +25,10 @@ var rootjQuery,
return this; return this;
} }
// init accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
// Handle HTML strings // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
if ( selector[ 0 ] === "<" && if ( selector[ 0 ] === "<" &&
...@@ -83,7 +87,7 @@ var rootjQuery, ...@@ -83,7 +87,7 @@ var rootjQuery,
// HANDLE: $(expr, $(...)) // HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) { } else if ( !context || context.jquery ) {
return ( context || rootjQuery ).find( selector ); return ( context || root ).find( selector );
// HANDLE: $(expr, context) // HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr) // (which is just equivalent to: $(context).find(expr)
...@@ -100,8 +104,8 @@ var rootjQuery, ...@@ -100,8 +104,8 @@ var rootjQuery,
// HANDLE: $(function) // HANDLE: $(function)
// Shortcut for document ready // Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) { } else if ( jQuery.isFunction( selector ) ) {
return typeof rootjQuery.ready !== "undefined" ? return typeof root.ready !== "undefined" ?
rootjQuery.ready( selector ) : root.ready( selector ) :
// Execute immediately if ready is not present // Execute immediately if ready is not present
selector( jQuery ); selector( jQuery );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment