Reverted optimization to jQuery function, fixing broken jQuery-as-context, added test (fix for #804)

This commit is contained in:
Jörn Zaefferer 2007-01-17 10:43:10 +00:00
parent 689739072f
commit 53e12752e0
2 changed files with 11 additions and 6 deletions

View File

@ -11,6 +11,11 @@ test("Basic requirements", function() {
ok( $, "$()" );
});
test("$()", function() {
var main = $("#main");
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
});
test("length", function() {
ok( $("div").length == 2, "Get Number of Elements Found" );
});

12
src/jquery/jquery.js vendored
View File

@ -38,14 +38,14 @@ var jQuery = function(a,c) {
// Handle HTML strings
if ( typeof a == "string" ) {
// HANDLE: $(html) -> $(array)
var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
if ( m )
a = jQuery.clean( [ m[1] ] );
a = m ?
// HANDLE: $(html) -> $(array)
jQuery.clean( [ m[1] ] ) :
// HANDLE: $(expr)
jQuery.find( a, c );
// HANDLE: $(expr)
else
return new jQuery( c ).find( a );
}
return this.setArray(