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
This commit is contained in:
parent
a165561dde
commit
03e28bae68
|
@ -21,7 +21,7 @@ window.wp = window.wp || {};
|
||||||
//
|
//
|
||||||
// Returns an array of all subviews.
|
// Returns an array of all subviews.
|
||||||
all: function() {
|
all: function() {
|
||||||
return _.flatten( this._views );
|
return _.flatten( _.values( this._views ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
// ### Get a selector's subviews
|
// ### Get a selector's subviews
|
||||||
|
|
Loading…
Reference in New Issue