@@ -17,14 +17,18 @@ var rootjQuery,
1717 // Shortcut simple #id case for speed
1818 rquickExpr = / ^ (?: \s * ( < [ \w \W ] + > ) [ ^ > ] * | # ( [ \w - ] + ) ) $ / ,
1919
20- init = jQuery . fn . init = function ( selector , context ) {
20+ init = jQuery . fn . init = function ( selector , context , root ) {
2121 var match , elem ;
2222
2323 // HANDLE: $(""), $(null), $(undefined), $(false)
2424 if ( ! selector ) {
2525 return this ;
2626 }
2727
28+ // init accepts an alternate rootjQuery
29+ // so migrate can support jQuery.sub (gh-2101)
30+ root = root || rootjQuery ;
31+
2832 // Handle HTML strings
2933 if ( typeof selector === "string" ) {
3034 if ( selector [ 0 ] === "<" &&
@@ -83,7 +87,7 @@ var rootjQuery,
8387
8488 // HANDLE: $(expr, $(...))
8589 } else if ( ! context || context . jquery ) {
86- return ( context || rootjQuery ) . find ( selector ) ;
90+ return ( context || root ) . find ( selector ) ;
8791
8892 // HANDLE: $(expr, context)
8993 // (which is just equivalent to: $(context).find(expr)
@@ -100,8 +104,8 @@ var rootjQuery,
100104 // HANDLE: $(function)
101105 // Shortcut for document ready
102106 } else if ( jQuery . isFunction ( selector ) ) {
103- return typeof rootjQuery . ready !== "undefined" ?
104- rootjQuery . ready ( selector ) :
107+ return typeof root . ready !== "undefined" ?
108+ root . ready ( selector ) :
105109 // Execute immediately if ready is not present
106110 selector ( jQuery ) ;
107111 }
0 commit comments