@@ -15,14 +15,18 @@ var rootjQuery,
15
15
// Shortcut simple #id case for speed
16
16
rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * | # ( [ \w - ] + ) ) $ / ,
17
17
18
- init = jQuery . fn . init = function ( selector , context ) {
18
+ init = jQuery . fn . init = function ( selector , context , root ) {
19
19
var match , elem ;
20
20
21
21
// HANDLE: $(""), $(null), $(undefined), $(false)
22
22
if ( ! selector ) {
23
23
return this ;
24
24
}
25
25
26
+ // init accepts an alternate rootjQuery
27
+ // so migrate can support jQuery.sub (gh-2101)
28
+ root = root || rootjQuery ;
29
+
26
30
// Handle HTML strings
27
31
if ( typeof selector === "string" ) {
28
32
if ( selector [ 0 ] === "<" &&
@@ -81,7 +85,7 @@ var rootjQuery,
81
85
82
86
// HANDLE: $(expr, $(...))
83
87
} else if ( ! context || context . jquery ) {
84
- return ( context || rootjQuery ) . find ( selector ) ;
88
+ return ( context || root ) . find ( selector ) ;
85
89
86
90
// HANDLE: $(expr, context)
87
91
// (which is just equivalent to: $(context).find(expr)
@@ -98,8 +102,8 @@ var rootjQuery,
98
102
// HANDLE: $(function)
99
103
// Shortcut for document ready
100
104
} else if ( jQuery . isFunction ( selector ) ) {
101
- return rootjQuery . ready !== undefined ?
102
- rootjQuery . ready ( selector ) :
105
+ return root . ready !== undefined ?
106
+ root . ready ( selector ) :
103
107
// Execute immediately if ready is not present
104
108
selector ( jQuery ) ;
105
109
}
0 commit comments