Added an improvement to quickExpr and some more tests for jQuery('html'). Fixes #4979.

This commit is contained in:
John Resig 2009-07-27 20:47:32 +00:00
parent 8c18dcdeb0
commit 18a6fbbb6a
2 changed files with 12 additions and 4 deletions

View file

@ -20,7 +20,7 @@ var jQuery = function( selector, context ) {
// A simple way to check for HTML strings or ID strings
// (both of which we optimize for)
quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
// Is it a simple selector
isSimple = /^.[^:#\[\.,]*$/,
@ -70,12 +70,12 @@ jQuery.fn = jQuery.prototype = {
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[3] );
elem = document.getElementById( match[2] );
if ( elem ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[3] ) return rootjQuery.find( selector );
if ( elem.id !== match[2] ) return rootjQuery.find( selector );
// Otherwise, we inject the element directly into the jQuery object
this.length++;