WordPress.org

Make WordPress Core

Changeset 36305


Ignore:
Timestamp:
01/15/2016 04:02:00 AM (4 years ago)
Author:
ericlewis
Message:

In wp.Backbone.Subviews, extract subviews with proper Underscore.js functions.

Subviews are stored internally on the Subview manager as an object. The object
is composed of key-value pairs where the key is a jQuery selector for a view,
and the value is an array of views that matching the selector.

To extract subviews, _.flatten() was used to collate the nested arrays of
views into a single view. However, _.flatten() is not intended to be used
for objects, and this unintended functionality breaks in newer versions of
Underscore.js.

Instead, we'll use _.values() to extract the arrays of views first,
and then flatten the array of arrays.

Props adamsilverstein.
See #34350.

File:
1 edited

Legend:

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

    r31471 r36305  
    2222        // Returns an array of all subviews.
    2323        all: function() {
    24             return _.flatten( this._views );
     24            return _.flatten( _.values( this._views ) );
    2525        },
    2626
Note: See TracChangeset for help on using the changeset viewer.