Commit 26bdbb80 authored by timmywil's avatar timmywil

Do jQuery.trim in less bytes (-5).

parent e2497c68
...@@ -36,8 +36,9 @@ var ...@@ -36,8 +36,9 @@ var
// Used for detecting and trimming whitespace // Used for detecting and trimming whitespace
core_rnotwhite = /\S/, core_rnotwhite = /\S/,
core_rspace = /\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 // A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (#9521) // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
...@@ -601,7 +602,7 @@ jQuery.extend({ ...@@ -601,7 +602,7 @@ jQuery.extend({
function( text ) { function( text ) {
return text == null ? return text == null ?
"" : "" :
text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); text.toString().replace( rtrim, "" );
}, },
// results is for internal usage only // results is for internal usage only
...@@ -913,11 +914,5 @@ if ( jQuery.browser.webkit ) { ...@@ -913,11 +914,5 @@ if ( jQuery.browser.webkit ) {
jQuery.browser.safari = true; 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 // All jQuery objects should point back to these
rootjQuery = jQuery(document); rootjQuery = jQuery(document);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment