mirror of
https://github.com/jquery/jquery.git
synced 2026-02-07 08:44:59 -05:00
Re-worked the logic for where .selector and .context are added for ID selectors (especially ones that aren't found). Fixes jQuery bug #3833.
This commit is contained in:
22
src/core.js
22
src/core.js
@@ -47,20 +47,16 @@ jQuery.fn = jQuery.prototype = {
|
||||
else {
|
||||
var elem = document.getElementById( match[3] );
|
||||
|
||||
// Make sure an element was located
|
||||
if ( elem ){
|
||||
// Handle the case where IE and Opera return items
|
||||
// by name instead of ID
|
||||
if ( elem.id != match[3] )
|
||||
return jQuery().find( selector );
|
||||
// Handle the case where IE and Opera return items
|
||||
// by name instead of ID
|
||||
if ( elem && elem.id != match[3] )
|
||||
return jQuery().find( selector );
|
||||
|
||||
// Otherwise, we inject the element directly into the jQuery object
|
||||
var ret = jQuery( elem );
|
||||
ret.context = document;
|
||||
ret.selector = selector;
|
||||
return ret;
|
||||
}
|
||||
selector = [];
|
||||
// Otherwise, we inject the element directly into the jQuery object
|
||||
var ret = jQuery( elem || [] );
|
||||
ret.context = document;
|
||||
ret.selector = selector;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// HANDLE: $(expr, [context])
|
||||
|
||||
Reference in New Issue
Block a user