aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2015-05-04 15:16:28 -0700
committerTimmy Willison <timmywillisn@gmail.com>2015-05-04 15:16:28 -0700
commit7a6931de689865f559bed26e797e8cbb5674bbce (patch)
treeddc085fc72b38657a5abf2ffa440f27f2413d5c2 /src/core
parent172cad80ac635d8900aa6a3504c89f38b320488e (diff)
downloadjquery-7a6931de689865f559bed26e797e8cbb5674bbce.tar.gz
jquery-7a6931de689865f559bed26e797e8cbb5674bbce.zip
Core: allow init to accept an alternate rootjQuery for migrate's sake
- This will be tested in migrate Fixes gh-2101
Diffstat (limited to 'src/core')
-rw-r--r--src/core/init.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/init.js b/src/core/init.js
index f49b560b6..861cb8351 100644
--- a/src/core/init.js
+++ b/src/core/init.js
@@ -15,7 +15,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)
@@ -23,6 +23,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] === "<" &&
@@ -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 );
}