Fix regexp for $.trim so it doesn't whack embedded spaces.
[jquery.git] / src / core.js
index e766529..2968d8d 100644 (file)
@@ -29,7 +29,7 @@ var jQuery = function( selector, context ) {
        rnotwhite = /\S/,
 
        // Used for trimming whitespace
-       rtrim = /^\s+|\s+$/g,
+       rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
 
        // Match a standalone tag
        rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
@@ -315,7 +315,7 @@ jQuery.extend({
        },
 
        isObjectLiteral: function( obj ) {
-               if ( toString.call(obj) !== "[object Object]" ) {
+               if ( toString.call(obj) !== "[object Object]" || typeof obj.nodeType === "number" ) {
                        return false;
                }
                
@@ -484,13 +484,14 @@ jQuery.extend({
                return ret;
        },
 
-       map: function( elems, callback ) {
+       // arg is for internal usage only
+       map: function( elems, callback, arg ) {
                var ret = [], value;
 
                // Go through the array, translating each of the items to their
                // new value (or values).
                for ( var i = 0, length = elems.length; i < length; i++ ) {
-                       value = callback( elems[ i ], i );
+                       value = callback( elems[ i ], i, arg );
 
                        if ( value != null ) {
                                ret[ ret.length ] = value;