Merge branch 'master' of github.com:jquery/jquery
authorjeresig <jeresig@gmail.com>
Mon, 30 Nov 2009 18:42:26 +0000 (13:42 -0500)
committerjeresig <jeresig@gmail.com>
Mon, 30 Nov 2009 18:42:26 +0000 (13:42 -0500)
src/core.js
test/unit/core.js

index e766529..5da31e6 100644 (file)
@@ -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>)?$/,
index 4044bd8..0640cf5 100644 (file)
@@ -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", "&nbsp;" );
+});
+
 test("isFunction", function() {
        expect(19);