Permalink
Browse files

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

- This will be tested in migrate

Fixes gh-2101
  • Loading branch information...
timmywil committed May 4, 2015
1 parent 172cad8 commit 7a6931de689865f559bed26e797e8cbb5674bbce
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/core/init.js
View
@@ -15,14 +15,18 @@ 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)
if ( !selector ) {
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] === "<" &&
@@ -81,7 +85,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)
@@ -98,8 +102,8 @@ var rootjQuery,
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
return rootjQuery.ready !== undefined ?
rootjQuery.ready( selector ) :
return root.ready !== undefined ?
root.ready( selector ) :
// Execute immediately if ready is not present
selector( jQuery );
}

0 comments on commit 7a6931d

Please sign in to comment.