]> source.dussan.org Git - jquery.git/commitdiff
Do jQuery.trim in less bytes (-5).
authortimmywil <timmywillisn@gmail.com>
Thu, 21 Jun 2012 19:57:12 +0000 (15:57 -0400)
committertimmywil <timmywillisn@gmail.com>
Thu, 21 Jun 2012 19:57:12 +0000 (15:57 -0400)
src/core.js

index 2bd8c4b32366585539db9595a212344edbb14292..9558fd060f5049f792dafe1396df1a127e93386e 100644 (file)
@@ -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);