Skip to main content

Bug Tracker

Side navigation

#2279 closed enhancement (fixed)

Opened February 04, 2008 07:50AM UTC

Closed March 09, 2010 02:14PM UTC

faster trim

Reported by: phpmyforum Owned by: flesler
Priority: minor Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: Cc: phpmyforum
Blocked by: Blocking:

Maybe everyone had read this already... I think jQuery would really benefit from this:

Attachments (2)
  • jquery-4763-trim.diff (0.4 KB) - added by DarkRyder February 20, 2008 02:55PM UTC.

    Diff against rev 2763.

  • trim[6001].diff (2.3 KB) - added by flesler December 25, 2008 08:25PM UTC.

    My trim function along with tests.

Change History (7)

Changed February 20, 2008 02:55PM UTC by DarkRyder comment:1

Seconded. Specifically, I'd suggest the following version, which is Steve's trim12 function with the null-value fix from bug 1395:

trim: function( text ) {
	var text = (text || "").replace(/^\\s\\s*/, ''),
	    ws = /\\s/,
	    i = text.length;
	while ( ws.test(text.charAt(--i)) ){}
	return text.slice(0, i + 1);

Changed April 24, 2008 07:06AM UTC by phpmyforum comment:2

No one interested?

Changed May 12, 2008 12:56AM UTC by flesler comment:3

I actually proposed one, and I think this trim12 is pretty much mine :)

Changed July 03, 2008 03:27AM UTC by flesler comment:4

need: ReviewPatch
owner: → flesler
status: newassigned

Changed November 29, 2008 06:03PM UTC by flesler comment:5

cc: → phpmyforum
need: PatchCommit

I think I'll add this trim function.

We need to do some tests to verify it's a good choice for most situations.

Changed February 09, 2009 03:43PM UTC by john comment:6

After fixing #4037, .trim() is no longer used in jQuery core - FYI.

Changed March 09, 2010 02:14PM UTC by john comment:7

resolution: → fixed
status: assignedclosed