From 03e28bae683ac73f3461c8d192d7a0dfd02e466b Mon Sep 17 00:00:00 2001 From: Eric Andrew Lewis Date: Fri, 15 Jan 2016 04:02:00 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@36305 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/wp-backbone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/js/wp-backbone.js b/src/wp-includes/js/wp-backbone.js index 0db9161faa..8cbfe6f508 100644 --- a/src/wp-includes/js/wp-backbone.js +++ b/src/wp-includes/js/wp-backbone.js @@ -21,7 +21,7 @@ window.wp = window.wp || {}; // // Returns an array of all subviews. all: function() { - return _.flatten( this._views ); + return _.flatten( _.values( this._views ) ); }, // ### Get a selector's subviews