Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/js/_enqueues/wp/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,12 +1334,20 @@ themes.view.Themes = wp.Backbone.View.extend({
*/
previous: function( args ) {
var self = this,
model, previousModel;
model, previousModel, index;

// Get the current theme.
model = self.collection.get( args[0] );

index = self.collection.indexOf( model );

// Bail early if the current theme is the first one or the model does not exist.
if ( index <= 0 ) {
return;
}

// Find the previous model within the collection.
previousModel = self.collection.at( self.collection.indexOf( model ) - 1 );
previousModel = self.collection.at( index - 1 );

if ( previousModel !== undefined ) {

Expand Down
Loading