Added tests for add() and fixed #770
This commit is contained in:
parent
84ecf3937b
commit
a5f9108a21
10
src/jquery/coreTest.js
vendored
10
src/jquery/coreTest.js
vendored
|
@ -27,6 +27,16 @@ test("get(Number)", function() {
|
||||||
ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
|
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($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
|
||||||
|
ok( x[0].id == "x1", "Check on-the-fly element1" );
|
||||||
|
ok( x[1].id == "x2", "Check on-the-fly element2" );
|
||||||
|
});
|
||||||
|
|
||||||
test("each(Function)", function() {
|
test("each(Function)", function() {
|
||||||
expect(1);
|
expect(1);
|
||||||
var div = $("div");
|
var div = $("div");
|
||||||
|
|
6
src/jquery/jquery.js
vendored
6
src/jquery/jquery.js
vendored
|
@ -951,9 +951,9 @@ jQuery.fn = jQuery.prototype = {
|
||||||
*/
|
*/
|
||||||
add: function(t) {
|
add: function(t) {
|
||||||
return this.set( jQuery.merge(
|
return this.set( jQuery.merge(
|
||||||
this.get(), typeof t == "string" ?
|
this.get(),
|
||||||
jQuery.find(t) :
|
typeof t == "string" ? jQuery.find(t) : t )
|
||||||
t.constructor == Array ? t : [t] ) );
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue