Media: in `wp.media.view.Toolbar.refresh()`, check for a selection before iterating over models.

Props chandrapatel.
Fixes #39511.


git-svn-id: https://develop.svn.wordpress.org/trunk@40050 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2017-02-08 19:16:34 +00:00
parent 4004400047
commit baff296dfa
2 changed files with 10 additions and 6 deletions

View File

@ -7724,9 +7724,11 @@ Toolbar = View.extend({
disabled = false;
// Prevent insertion of attachments if any of them are still uploading
disabled = _.some( selection.models, function( attachment ) {
return attachment.get('uploading') === true;
});
if ( selection && selection.models ) {
disabled = _.some( selection.models, function( attachment ) {
return attachment.get('uploading') === true;
});
}
if ( requires.selection && selection && ! selection.length ) {
disabled = true;

View File

@ -141,9 +141,11 @@ Toolbar = View.extend({
disabled = false;
// Prevent insertion of attachments if any of them are still uploading
disabled = _.some( selection.models, function( attachment ) {
return attachment.get('uploading') === true;
});
if ( selection && selection.models ) {
disabled = _.some( selection.models, function( attachment ) {
return attachment.get('uploading') === true;
});
}
if ( requires.selection && selection && ! selection.length ) {
disabled = true;