aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortimmywil <timmywillisn@gmail.com>2012-06-21 15:57:12 -0400
committertimmywil <timmywillisn@gmail.com>2012-06-21 15:57:12 -0400
commit26bdbb806eeb1d8e1881b3fc11ff298eb4d1dca0 (patch)
treec9b6aa6fd01e23853c171a45c5152a8d3880279d
parente2497c682f26b7916d76cb2896c6fe621b376d82 (diff)
downloadjquery-26bdbb806eeb1d8e1881b3fc11ff298eb4d1dca0.tar.gz
jquery-26bdbb806eeb1d8e1881b3fc11ff298eb4d1dca0.zip
Do jQuery.trim in less bytes (-5).
-rw-r--r--src/core.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/core.js b/src/core.js
index 2bd8c4b32..9558fd060 100644
--- a/src/core.js
+++ b/src/core.js
@@ -36,8 +36,9 @@ var
// Used for detecting and trimming whitespace
core_rnotwhite = /\S/,
core_rspace = /\s+/,
- trimLeft = /^\s+/,
- trimRight = /\s+$/,
+
+ // IE doesn't match non-breaking spaces with \s
+ rtrim = core_rnotwhite.test("\xA0") ? (/^[\s\xA0]+|[\s\xA0]+$/g) : /^\s+|\s+$/g,
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
@@ -601,7 +602,7 @@ jQuery.extend({
function( text ) {
return text == null ?
"" :
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
+ text.toString().replace( rtrim, "" );
},
// results is for internal usage only
@@ -913,11 +914,5 @@ if ( jQuery.browser.webkit ) {
jQuery.browser.safari = true;
}
-// IE doesn't match non-breaking spaces with \s
-if ( core_rnotwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
-}
-
// All jQuery objects should point back to these
rootjQuery = jQuery(document);