From a5f9108a2109b2ed5778af860b0928d8e6b0fdd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 10 Jan 2007 09:37:22 +0000 Subject: [PATCH] Added tests for add() and fixed #770 --- src/jquery/coreTest.js | 10 ++++++++++ src/jquery/jquery.js | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 7466c4c..1c81e08 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -27,6 +27,16 @@ test("get(Number)", function() { ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" ); }); +test("add(String|Element|Array)", function() { + isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); + + ok( $([]).add($("#form")[0].elements).length > 13, "Check elements from array" ); + + var x = $([]).add($("

xxx

")).add($("

xxx

")); + ok( x[0].id == "x1", "Check on-the-fly element1" ); + ok( x[1].id == "x2", "Check on-the-fly element2" ); +}); + test("each(Function)", function() { expect(1); var div = $("div"); diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index f927a35..0aac026 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -951,9 +951,9 @@ jQuery.fn = jQuery.prototype = { */ add: function(t) { return this.set( jQuery.merge( - this.get(), typeof t == "string" ? - jQuery.find(t) : - t.constructor == Array ? t : [t] ) ); + this.get(), + typeof t == "string" ? jQuery.find(t) : t ) + ); }, /** -- 1.7.10.4