diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2007-01-17 10:43:10 +0000 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2007-01-17 10:43:10 +0000 |
commit | 53e12752e00c2a86757ec15a0c871dee8ccd1bea (patch) | |
tree | 07fc0e1649657b4059afa14e0b36322171402319 /src | |
parent | 689739072f858d5e48d2c0394204dc17eba9e4e1 (diff) | |
download | jquery-53e12752e00c2a86757ec15a0c871dee8ccd1bea.tar.gz jquery-53e12752e00c2a86757ec15a0c871dee8ccd1bea.zip |
Reverted optimization to jQuery function, fixing broken jQuery-as-context, added test (fix for #804)
Diffstat (limited to 'src')
-rw-r--r-- | src/jquery/coreTest.js | 5 | ||||
-rw-r--r-- | 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 5dd9d8058..0f1e0f5a8 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 9dcccb93a..ca4051f3d 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( |