aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/init.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/init.js')
-rw-r--r--src/core/init.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/core/init.js b/src/core/init.js
index 861cb8351..a00d58791 100644
--- a/src/core/init.js
+++ b/src/core/init.js
@@ -1,5 +1,5 @@
// Initialize a jQuery object
-define([
+define( [
"../core",
"../var/document",
"./var/rsingleTag",
@@ -23,13 +23,13 @@ var rootjQuery,
return this;
}
- // init accepts an alternate rootjQuery
+ // Method 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] === "<" &&
+ if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
selector.length >= 3 ) {
@@ -41,23 +41,24 @@ var rootjQuery,
}
// Match html or make sure no context is specified for #id
- if ( match && (match[1] || !context) ) {
+ if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
+ if ( match[ 1 ] ) {
+ context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML(
- match[1],
+ match[ 1 ],
context && context.nodeType ? context.ownerDocument || context : document,
true
) );
// HANDLE: $(html, props)
- if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+ if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
+
// Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
@@ -73,11 +74,12 @@ var rootjQuery,
// HANDLE: $(#id)
} else {
- elem = document.getElementById( match[2] );
+ elem = document.getElementById( match[ 2 ] );
if ( elem ) {
+
// Inject the element directly into the jQuery object
- this[0] = elem;
+ this[ 0 ] = elem;
this.length = 1;
}
return this;
@@ -95,7 +97,7 @@ var rootjQuery,
// HANDLE: $(DOMElement)
} else if ( selector.nodeType ) {
- this[0] = selector;
+ this[ 0 ] = selector;
this.length = 1;
return this;
@@ -104,6 +106,7 @@ var rootjQuery,
} else if ( jQuery.isFunction( selector ) ) {
return root.ready !== undefined ?
root.ready( selector ) :
+
// Execute immediately if ready is not present
selector( jQuery );
}
@@ -119,4 +122,4 @@ rootjQuery = jQuery( document );
return init;
-});
+} );