Media: Check if the item is defined before setting the skipHistory property in media frame router.

This avoids a JS error when refreshing the "Attachment details" modal for an item that is not currently queried.

Follow-up to [41021].

Props Mista-Flo, mukesh27.
Fixes #51395.

git-svn-id: https://develop.svn.wordpress.org/trunk@49062 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-09-27 08:48:05 +00:00
parent 0c4958bdbc
commit 7b64dc237a

View File

@ -43,9 +43,9 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R
// Trigger the media frame to open the correct item.
item = library.findWhere( { id: parseInt( query, 10 ) } );
item.set( 'skipHistory', true );
if ( item ) {
item.set( 'skipHistory', true );
frame.trigger( 'edit:attachment', item );
} else {
item = media.attachment( query );