From aa6b7069e6120aa0aa4d7a090821fa3c57168180 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Mon, 19 Nov 2012 10:41:24 +0000 Subject: [PATCH] Media: Add a method to fetch the first subview. see #21390. git-svn-id: https://develop.svn.wordpress.org/trunk@22682 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/media-views.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index da69d64222..2b0c7fbd55 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -592,6 +592,19 @@ return this._views[ selector ]; }, + // ### Get a selector's first subview + // + // Fetches the first subview that matches a given `selector`. + // + // If no `selector` is provided, it will grab the first subview + // attached to the view's root. + // + // Useful when a selector only has one subview at a time. + first: function( selector ) { + var views = this.get( selector ); + return views && views.length ? views[0] : null; + }, + // ### Register subview(s) // // Registers any number of `views` to a `selector`.