jQuery: The Write Less, Do More JavaScript Library

Changeset 4041

Show
Ignore:
Timestamp:
12/06/07 19:51:00 (8 months ago)
Author:
joern.zaefferer
Message:

Fix for #2002

Location:
trunk/jquery
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/core.js

    r4031 r4041  
    341341 
    342342    add: function( selector ) { 
    343         return this.pushStack( jQuery.merge(  
     343        return !selector ? this : this.pushStack( jQuery.merge(  
    344344            this.get(), 
    345345            selector.constructor == String ?  
  • trunk/jquery/test/unit/core.js

    r4031 r4041  
    209209}); 
    210210 
    211 test("add(String|Element|Array)", function() { 
    212     expect(7); 
     211test("add(String|Element|Array|undefined)", function() { 
     212    expect(8); 
    213213    isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); 
    214214    isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" ); 
     
    222222    ok( x[0].id == "x1", "Check on-the-fly element1" ); 
    223223    ok( x[1].id == "x2", "Check on-the-fly element2" ); 
     224     
     225    var notDefined; 
     226    equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing." ); 
    224227}); 
    225228