Sanity check $uploaderToggler in wp.media.view.UploaderInline.

This ensures `$uploaderToggler` exists before checking length so any views
extending or scripts accessing this view, won't encounter errors that stop execution.

Props Blackbam, yahil.
Fixes #41231.


git-svn-id: https://develop.svn.wordpress.org/trunk@41009 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe McGill 2017-07-06 00:40:59 +00:00
parent a828890ce2
commit 3eb767b5c3
2 changed files with 4 additions and 4 deletions

View File

@ -8228,13 +8228,13 @@ UploaderInline = View.extend({
},
show: function() {
this.$el.removeClass( 'hidden' );
if ( this.controller.$uploaderToggler.length ) {
if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) {
this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' );
}
},
hide: function() {
this.$el.addClass( 'hidden' );
if ( this.controller.$uploaderToggler.length ) {
if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) {
this.controller.$uploaderToggler
.attr( 'aria-expanded', 'false' )
// Move focus back to the toggle button when closing the uploader.

View File

@ -119,13 +119,13 @@ UploaderInline = View.extend({
},
show: function() {
this.$el.removeClass( 'hidden' );
if ( this.controller.$uploaderToggler.length ) {
if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) {
this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' );
}
},
hide: function() {
this.$el.addClass( 'hidden' );
if ( this.controller.$uploaderToggler.length ) {
if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) {
this.controller.$uploaderToggler
.attr( 'aria-expanded', 'false' )
// Move focus back to the toggle button when closing the uploader.