diff options
-rw-r--r-- | src/core/init.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/init.js b/src/core/init.js index 115164852..52999d4ea 100644 --- a/src/core/init.js +++ b/src/core/init.js @@ -17,7 +17,7 @@ var rootjQuery, // Shortcut simple #id case for speed rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, - init = jQuery.fn.init = function( selector, context ) { + init = jQuery.fn.init = function( selector, context, root ) { var match, elem; // HANDLE: $(""), $(null), $(undefined), $(false) @@ -25,6 +25,10 @@ var rootjQuery, return this; } + // init accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + // Handle HTML strings if ( typeof selector === "string" ) { if ( selector[ 0 ] === "<" && @@ -83,7 +87,7 @@ var rootjQuery, // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); + return ( context || root ).find( selector ); // HANDLE: $(expr, context) // (which is just equivalent to: $(context).find(expr) @@ -100,8 +104,8 @@ var rootjQuery, // HANDLE: $(function) // Shortcut for document ready } else if ( jQuery.isFunction( selector ) ) { - return typeof rootjQuery.ready !== "undefined" ? - rootjQuery.ready( selector ) : + return typeof root.ready !== "undefined" ? + root.ready( selector ) : // Execute immediately if ready is not present selector( jQuery ); } |