Skip to content

Commit df6e02a

Browse files
committed
Merge branch 'master' of github.com:jquery/jquery
2 parents 90ba57c + 17955ca commit df6e02a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var jQuery = function( selector, context ) {
2929
rnotwhite = /\S/,
3030

3131
// Used for trimming whitespace
32-
rtrim = /^\s+|\s+$/g,
32+
rtrim = /(\s|\u00A0)+|(\s|\u00A0)+$/g,
3333

3434
// Match a standalone tag
3535
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,

test/unit/core.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ test("noConflict", function() {
189189
jQuery = $$;
190190
});
191191

192+
test("trim", function() {
193+
expect(4);
194+
195+
var nbsp = String.fromCharCode(160);
196+
197+
equals( jQuery.trim("hello "), "hello", "trailing space" );
198+
equals( jQuery.trim(" hello"), "hello", "leading space" );
199+
equals( jQuery.trim(" hello "), "hello", "space on both sides" );
200+
equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", "&nbsp;" );
201+
});
202+
192203
test("isFunction", function() {
193204
expect(19);
194205

0 commit comments

Comments
 (0)