Skip to main content

Bug Tracker

Side navigation

Ticket #2279: jquery-4763-trim.diff
File jquery-4763-trim.diff, 0.4 KB (added by DarkRyder, February 20, 2008 02:55PM UTC)

Diff against rev 2763.

Index: core.js
===================================================================
--- core.js	(revision 4789)
+++ core.js	(working copy)
@@ -1114,7 +1114,11 @@
 	},
 	
 	trim: function( text ) {
-		return (text || "").replace( /^\s+|\s+$/g, "" );
+		var text = (text || "").replace(/^\s\s*/, ''),
+		    ws = /\s/,
+		    i = text.length;
+		while ( ws.test(text.charAt(--i)) );
+		return text.slice(0, i + 1);
 	},
 
 	makeArray: function( array ) {

Download in other formats:

Original Format