aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core.js2
-rw-r--r--test/unit/core.js11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/core.js b/src/core.js
index 3ba2a859d..bdc6b2f5e 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 4044bd856..0640cf5ce 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", "&nbsp;" );
+});
+
test("isFunction", function() {
expect(19);