Landing a faster trim method. Based upon the work by Travis Hardiman and DBJDBJ. More details here: http://forum.jquery.com/topic/faster-jquery-trim Fixes #2279, #4452, and #4835.

This commit is contained in:
jeresig 2010-03-09 09:14:27 -05:00
parent 0a307b332e
commit 141ad3c3e2
3 changed files with 36 additions and 24 deletions

View file

@ -201,14 +201,20 @@ test("noConflict", function() {
});
test("trim", function() {
expect(4);
expect(9);
var nbsp = String.fromCharCode(160);
var nbsp = String.fromCharCode(160);
equals( jQuery.trim("hello "), "hello", "trailing space" );
equals( jQuery.trim(" hello"), "hello", "leading space" );
equals( jQuery.trim(" hello "), "hello", "space on both sides" );
equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
equals( jQuery.trim("hello "), "hello", "trailing space" );
equals( jQuery.trim(" hello"), "hello", "leading space" );
equals( jQuery.trim(" hello "), "hello", "space on both sides" );
equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
equals( jQuery.trim(), "", "Nothing in." );
equals( jQuery.trim( undefined ), "", "Undefined" );
equals( jQuery.trim( null ), "", "Null" );
equals( jQuery.trim( 5 ), "5", "Number" );
equals( jQuery.trim( false ), "false", "Boolean" );
});
test("isPlainObject", function() {