jquery core: removing needless 'else' and 'new' in $.fn.init.
This commit is contained in:
parent
46931d3146
commit
69d9abff2c
1 changed files with 8 additions and 13 deletions
21
src/core.js
21
src/core.js
|
@ -36,9 +36,9 @@ jQuery.fn = jQuery.prototype = {
|
||||||
this[0] = selector;
|
this[0] = selector;
|
||||||
this.length = 1;
|
this.length = 1;
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
// Handle HTML strings
|
// Handle HTML strings
|
||||||
} else if ( typeof selector == "string" ) {
|
if ( typeof selector == "string" ) {
|
||||||
// Are we dealing with HTML string or an ID?
|
// Are we dealing with HTML string or an ID?
|
||||||
var match = quickExpr.exec( selector );
|
var match = quickExpr.exec( selector );
|
||||||
|
|
||||||
|
@ -54,32 +54,27 @@ jQuery.fn = jQuery.prototype = {
|
||||||
var elem = document.getElementById( match[3] );
|
var elem = document.getElementById( match[3] );
|
||||||
|
|
||||||
// Make sure an element was located
|
// Make sure an element was located
|
||||||
if ( elem )
|
if ( elem ){
|
||||||
// Handle the case where IE and Opera return items
|
// Handle the case where IE and Opera return items
|
||||||
// by name instead of ID
|
// by name instead of ID
|
||||||
if ( elem.id != match[3] )
|
if ( elem.id != match[3] )
|
||||||
return jQuery().find( selector );
|
return jQuery().find( selector );
|
||||||
|
|
||||||
// Otherwise, we inject the element directly into the jQuery object
|
// Otherwise, we inject the element directly into the jQuery object
|
||||||
else {
|
return jQuery( elem );
|
||||||
this[0] = elem;
|
}
|
||||||
this.length = 1;
|
selector = [];
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
selector = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HANDLE: $(expr, [context])
|
// HANDLE: $(expr, [context])
|
||||||
// (which is just equivalent to: $(content).find(expr)
|
// (which is just equivalent to: $(content).find(expr)
|
||||||
} else
|
} else
|
||||||
return new jQuery( context ).find( selector );
|
return jQuery( context ).find( selector );
|
||||||
|
|
||||||
// HANDLE: $(function)
|
// HANDLE: $(function)
|
||||||
// Shortcut for document ready
|
// Shortcut for document ready
|
||||||
} else if ( jQuery.isFunction( selector ) )
|
} else if ( jQuery.isFunction( selector ) )
|
||||||
return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
|
return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
|
||||||
|
|
||||||
return this.setArray(jQuery.makeArray(selector));
|
return this.setArray(jQuery.makeArray(selector));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue