Skip to content

Commit 7a6931d

Browse files
committed
Core: allow init to accept an alternate rootjQuery for migrate's sake
- This will be tested in migrate Fixes gh-2101
1 parent 172cad8 commit 7a6931d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/core/init.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ var rootjQuery,
1515
// Shortcut simple #id case for speed
1616
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
1717

18-
init = jQuery.fn.init = function( selector, context ) {
18+
init = jQuery.fn.init = function( selector, context, root ) {
1919
var match, elem;
2020

2121
// HANDLE: $(""), $(null), $(undefined), $(false)
2222
if ( !selector ) {
2323
return this;
2424
}
2525

26+
// init accepts an alternate rootjQuery
27+
// so migrate can support jQuery.sub (gh-2101)
28+
root = root || rootjQuery;
29+
2630
// Handle HTML strings
2731
if ( typeof selector === "string" ) {
2832
if ( selector[0] === "<" &&
@@ -81,7 +85,7 @@ var rootjQuery,
8185

8286
// HANDLE: $(expr, $(...))
8387
} else if ( !context || context.jquery ) {
84-
return ( context || rootjQuery ).find( selector );
88+
return ( context || root ).find( selector );
8589

8690
// HANDLE: $(expr, context)
8791
// (which is just equivalent to: $(context).find(expr)
@@ -98,8 +102,8 @@ var rootjQuery,
98102
// HANDLE: $(function)
99103
// Shortcut for document ready
100104
} else if ( jQuery.isFunction( selector ) ) {
101-
return rootjQuery.ready !== undefined ?
102-
rootjQuery.ready( selector ) :
105+
return root.ready !== undefined ?
106+
root.ready( selector ) :
103107
// Execute immediately if ready is not present
104108
selector( jQuery );
105109
}

0 commit comments

Comments
 (0)