From: jeresig Date: Mon, 30 Nov 2009 18:42:26 +0000 (-0500) Subject: Merge branch 'master' of github.com:jquery/jquery X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=df6e02a4a7d8da037ebdb812e6b92a067223a6ea;hp=90ba57ce6d84653b4533569d88d4af6b9a50426b;p=jquery.git Merge branch 'master' of github.com:jquery/jquery --- diff --git a/src/core.js b/src/core.js index e766529..5da31e6 100644 --- a/src/core.js +++ b/src/core.js @@ -29,7 +29,7 @@ var jQuery = function( selector, context ) { rnotwhite = /\S/, // Used for trimming whitespace - rtrim = /^\s+|\s+$/g, + rtrim = /(\s|\u00A0)+|(\s|\u00A0)+$/g, // Match a standalone tag rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, diff --git a/test/unit/core.js b/test/unit/core.js index 4044bd8..0640cf5 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -189,6 +189,17 @@ test("noConflict", function() { jQuery = $$; }); +test("trim", function() { + expect(4); + + 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", " " ); +}); + test("isFunction", function() { expect(19);