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( $, "$()" ); 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() { test("length", function() {
ok( $("div").length == 2, "Get Number of Elements Found" ); ok( $("div").length == 2, "Get Number of Elements Found" );
}); });

10
src/jquery/jquery.js vendored
View file

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