Bug Tracker

Custom Query (13852 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (10 - 12 of 13852)

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Ticket Resolution Summary Owner Reporter
#2002 fixed Optimization in add() breaks API, undefined as argument throws error joern
Description

In the latest revision, add() was optimized to check for String arguments (selector.constructor == String). This breaks compability with existing code that relies on the 1.2.1 (I guess since 1.0) behaviour to silently ignore when undefined is passed as an argument.

The validation plugin relies on the old behaviour - if the new one intended behaviour, I need to release an update that handles the change before 1.2.2 gets out. Please give me a note in that case.

Testcase:

Index: test/unit/core.js
===================================================================
--- test/unit/core.js	(revision 4012)
+++ test/unit/core.js	(working copy)
@@ -183,8 +183,8 @@
 	ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" );
 });
 
-test("add(String|Element|Array)", function() {
-	expect(7);
+test("add(String|Element|Array|undefined)", function() {
+	expect(8);
 	isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
 	isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
 	ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
@@ -196,6 +196,9 @@
 	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" );
+	
+	var notDefined;
+	equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing." );
 });
 
 test("each(Function)", function() {

Patch:

Index: src/core.js
===================================================================
--- src/core.js	(revision 4012)
+++ src/core.js	(working copy)
@@ -340,6 +340,8 @@
 	},
 
 	add: function( selector ) {
+		if (!selector)
+			return this;
 		return this.pushStack( jQuery.merge( 
 			this.get(),
 			selector.constructor == String ? 
#2026 wontfix Hard to get at original appendTo/replaceAll stuff john
Description

For example:

$("<p>foo</p>") // [<p>]
  .appendTo("div") // [<p>]

There's no way to get at all of the paragraphs that were appended. I'd like to propose that if any element cloning is done then appendTo/replaceAll/etc. should return the cloned results, like so:

$("<p>foo</p>") // [<p>]
  .appendTo("div") // [<p>, <p>, <p>, <p>, ...]
#2027 fixed appendTo/replaceAll/etc. needs to control event cloning john
Description

Currently if you do appendTo/replaceAll etc. elements will most likely get cloned when they're added to the DOM - however, there's no way to specify if events should be cloned on the original element (like it's specified on the .clone() method). Additionally, .domManip() doesn't use the clone method, it should do that as well.

At first I thought #2026 was the right solution to this problem - but this is the right one.

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Note: See TracQuery for help on using queries.