Skip to main content

Bug Tracker

Side navigation

Ticket #962: patch-962.txt


File patch-962.txt, 1.6 KB (added by john, February 26, 2007 11:33PM UTC)

A patch and test for appending trailing whitespace.

Index: src/jquery/coreTest.js
===================================================================
--- src/jquery/coreTest.js	(revision 1434)
+++ src/jquery/coreTest.js	(working copy)
@@ -213,7 +213,7 @@
 });
 
 test("append(String|Element|Array<Element>|jQuery)", function() {
-	expect(10);
+	expect(11);
 	var defaultText = 'Try them out:'
 	var result = $('#first').append('<b>buga</b>');
 	ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
@@ -239,6 +239,10 @@
 	ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
 
 	reset();
+	$("#sap").append( " text with spaces " );
+	ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
+
+	reset();
 	ok( $("#sap").append([]), "Check for appending an empty array." );
 	ok( $("#sap").append(""), "Check for appending an empty string." );
 	ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
@@ -698,4 +702,4 @@
 	    //console.log( close[0]); // it's the <a> and not a <span> element
 	    return false;
 	}).click();
-});
\ No newline at end of file
+});
Index: src/jquery/jquery.js
===================================================================
--- src/jquery/jquery.js	(revision 1434)
+++ src/jquery/jquery.js	(working copy)
@@ -1445,7 +1445,7 @@
 					[0,"",""];
 
 				// Go to html and back, then peel off extra wrappers
-				div.innerHTML = wrap[1] + s + wrap[2];
+				div.innerHTML = wrap[1] + arg + wrap[2];
 				
 				// Move to the right depth
 				while ( wrap[0]-- )

Download in other formats:

Original Format