From 028d37832227ec4bea39b43dc6f607ff3acac126 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: http://core.svn.wordpress.org/trunk@22682 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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`.