Make WordPress Core

Changeset 26702


Ignore:
Timestamp:
12/05/2013 11:12:59 PM (11 years ago)
Author:
nacin
Message:

Customizer: Revert [26548], removing _.isEqual() for proper object comparison.

This broke the customizer in IE 11, with possibly other side effects. Revisit in 3.9.

Also reverts [26632].

see #26061 (reopens), fixes #26438.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-base.js

    r26632 r26702  
    177177
    178178            // Bail if the sanitized value is null or unchanged.
    179             if ( null === to || this.isEqual( to ) )
     179            if ( null === to || this._value === to )
    180180                return this;
    181181
     
    252252            });
    253253            return this;
    254         },
    255 
    256         /**
    257          * Internal recursive comparison function for `isEqual`.
    258          * Copied from Underscore.js.
    259          */
    260         /* jshint ignore:start */
    261         _eq: function(a, b, aStack, bStack) {
    262             if (a === b) return a !== 0 || 1 / a == 1 / b;
    263             if (a == null || b == null) return a === b;
    264 
    265             var className = toString.call(a);
    266             if (className != toString.call(b)) return false;
    267             switch (className) {
    268                 case '[object String]':
    269                     return a == String(b);
    270                 case '[object Number]':
    271                     return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
    272                 case '[object Date]':
    273                 case '[object Boolean]':
    274                     return +a == +b;
    275                 case '[object RegExp]':
    276                     return a.source == b.source &&
    277                                 a.global == b.global &&
    278                                 a.multiline == b.multiline &&
    279                                 a.ignoreCase == b.ignoreCase;
    280             }
    281             if (typeof a != 'object' || typeof b != 'object') return false;
    282             var length = aStack.length;
    283             while (length--) {
    284                 if (aStack[length] == a) return bStack[length] == b;
    285             }
    286             var aCtor = a.constructor, bCtor = b.constructor;
    287             if (aCtor !== bCtor && !((typeof aCtor === 'function') && (aCtor instanceof aCtor) &&
    288                                     (typeof bCtor === 'function') && (bCtor instanceof bCtor))) {
    289                 return false;
    290             }
    291             aStack.push(a);
    292             bStack.push(b);
    293             var size = 0, result = true;
    294 
    295             if (className == '[object Array]') {
    296                 size = a.length;
    297                 result = size == b.length;
    298                 if (result) {
    299                     while (size--) {
    300                         if (!(result = this._eq(a[size], b[size], aStack, bStack))) break;
    301                     }
    302                 }
    303             } else {
    304                 for (var key in a) {
    305                     if (hasOwnProperty.call(a, key)) {
    306                         size++;
    307                         if (!(result = hasOwnProperty.call(b, key) && this._eq(a[key], b[key], aStack, bStack))) break;
    308                     }
    309                 }
    310                 if (result) {
    311                     for (key in b) {
    312                         if (hasOwnProperty.call(b, key) && !(size--)) break;
    313                     }
    314                     result = !size;
    315                 }
    316             }
    317             aStack.pop();
    318             bStack.pop();
    319             return result;
    320         },
    321         /* jshint ignore:end */
    322 
    323         isEqual: function( to ) {
    324             return this._eq( this._value, to, [], [] );
    325254        }
    326255    });
Note: See TracChangeset for help on using the changeset viewer.