From 53e12752e00c2a86757ec15a0c871dee8ccd1bea Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 17 Jan 2007 10:43:10 +0000 Subject: [PATCH] Reverted optimization to jQuery function, fixing broken jQuery-as-context, added test (fix for #804) --- src/jquery/coreTest.js | 5 +++++ src/jquery/jquery.js | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 5dd9d80..0f1e0f5 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -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" ); }); diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 9dcccb9..ca4051f 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -38,14 +38,14 @@ var jQuery = function(a,c) { // Handle HTML strings if ( typeof a == "string" ) { + // HANDLE: $(html) -> $(array) var m = /^[^<]*(<.+>)[^>]*$/.exec(a); - - a = m ? - // HANDLE: $(html) -> $(array) - jQuery.clean( [ m[1] ] ) : + if ( m ) + a = jQuery.clean( [ m[1] ] ); - // HANDLE: $(expr) - jQuery.find( a, c ); + // HANDLE: $(expr) + else + return new jQuery( c ).find( a ); } return this.setArray( -- 1.7.10.4