aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2014-02-13 14:48:58 -0800
committerMichał Gołębiowski <m.goleb@gmail.com>2014-02-13 14:48:58 -0800
commiteda283d0e4d59074ae98af0fdc2951e6c109d5fd (patch)
treed7103e33ef00607750bdac64843cb78780175f73 /src
parentd792e40fbc2b46346bc518483ac31772c55ebb12 (diff)
downloadjquery-eda283d0e4d59074ae98af0fdc2951e6c109d5fd.tar.gz
jquery-eda283d0e4d59074ae98af0fdc2951e6c109d5fd.zip
Core: Fix trim in Android<4.1
Diffstat (limited to 'src')
-rw-r--r--src/core.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js
index 67b6e7199..11c232765 100644
--- a/src/core.js
+++ b/src/core.js
@@ -24,6 +24,10 @@ var
return new jQuery.fn.init( selector, context );
},
+ // Support: Android<4.1
+ // Make sure we trim BOM and NBSP
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
// Matches dashed string for camelizing
rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi,
@@ -336,9 +340,21 @@ jQuery.extend({
return obj;
},
- trim: function( text ) {
- return text == null ? "" : trim.call( text );
- },
+ // Support: Android<4.1
+ // Use native String.trim function wherever possible
+ trim: trim && !trim.call("\uFEFF\xA0") ?
+ function( text ) {
+ return text == null ?
+ "" :
+ trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
// results is for internal usage only
makeArray: function( arr, results ) {