Permalink
Browse files

Remove BOM in jQuery.trim.

  • Loading branch information...
1 parent aa1350d commit c51d611fb903183d88b73d17a5ab96e70a8aba0f @wwalser committed Aug 16, 2012
Showing with 7 additions and 3 deletions.
  1. +2 −2 src/core.js
  2. +5 −1 test/unit/core.js
View
4 src/core.js
@@ -37,8 +37,8 @@ var
core_rnotwhite = /\S/,
core_rspace = /\s+/,
- // IE doesn't match non-breaking spaces with \s
- rtrim = core_rnotwhite.test("\xA0") ? (/^[\s\xA0]+|[\s\xA0]+$/g) : /^\s+|\s+$/g,
+ // IE doesn't match many whitespace characters with \s
+ rtrim = core_rnotwhite.test("\xA0") ? /^[\s\xA0\uFEFF]+|[\s\xA0\uFEFF]+$/g : /^\s+|\s+$/g,
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
View
6 test/unit/core.js
@@ -264,7 +264,7 @@ test("noConflict", function() {
});
test("trim", function() {
- expect(9);
+ expect(12);
var nbsp = String.fromCharCode(160);
@@ -278,6 +278,10 @@ test("trim", function() {
equal( jQuery.trim( null ), "", "Null" );
equal( jQuery.trim( 5 ), "5", "Number" );
equal( jQuery.trim( false ), "false", "Boolean" );
+
+ equal( jQuery.trim(" ").length, 0, "space should be trimmed");
+ equal( jQuery.trim("\xA0").length, 0, "nbsp should be trimmed");
+ equal( jQuery.trim("\uFEFF").length, 0, "zwsp should be trimmed");
});
test("type", function() {

0 comments on commit c51d611

Please sign in to comment.