Fix/test for #861
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 23 Jan 2007 16:58:03 +0000 (16:58 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 23 Jan 2007 16:58:03 +0000 (16:58 +0000)
src/jquery/coreTest.js
src/jquery/jquery.js

index a9c3e26..a7b470e 100644 (file)
@@ -663,3 +663,13 @@ test("eq(), gt(), lt(), contains()", function() {
        isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );\r
        isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );\r
 });\r
+\r
+test("click() context", function() {\r
+       $('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {\r
+           var close = $('spanx', this); // same with $(this).find('span');\r
+           ok( close.length == 0, "Element does not exist, length must be zero" );\r
+           ok( !close[0], "Element does not exist, direct access to element must return undefined" );\r
+           //console.log( close[0]); // it's the <a> and not a <span> element\r
+           return false;\r
+       }).click();\r
+});
\ No newline at end of file
index d9f5b8a..b720954 100644 (file)
@@ -257,9 +257,10 @@ jQuery.fn = jQuery.prototype = {
         * @cat Core
         */
        pushStack: function( a ) {
-               var ret = jQuery(this);
+               var ret = jQuery(a);
                ret.prevObject = this;
-               return ret.setArray( a );
+               //return ret.setArray( a );
+               return ret;
        },
        
        /**
@@ -803,7 +804,7 @@ jQuery.fn = jQuery.prototype = {
        find: function(t) {
                return this.pushStack( jQuery.map( this, function(a){
                        return jQuery.find(t,a);
-               }) );
+               }), t );
        },
 
        /**