[wp-trac] [WordPress Trac] #41231: media-views.js: Cannot read .length of undefined (this.controller.$uploaderToggler.length)

WordPress Trac noreply at wordpress.org
Mon Jul 3 16:59:50 UTC 2017


#41231: media-views.js: Cannot read .length of undefined
(this.controller.$uploaderToggler.length)
----------------------------------------+-----------------------------
 Reporter:  Blackbam                    |      Owner:
     Type:  defect (bug)                |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  Media                       |    Version:  4.8
 Severity:  normal                      |   Keywords:
  Focuses:  javascript, administration  |
----------------------------------------+-----------------------------
 Some change in media-views.js destroyed all my custom scripts regarding
 media libraries when updating WordPress to the most recent version. I do
 not know what $uploaderToggler is however if it is not defined the script
 should not stop execution.


 media-views.js lines 8228 - 8242 - currently:

 {{{

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


 }}}

 How to fix:

 {{{

         show: function() {
                 this.$el.removeClass( 'hidden' );
                 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 &&
 this.controller.$uploaderToggler.length ) {
                         this.controller.$uploaderToggler
                                 .attr( 'aria-expanded', 'false' )
                                 // Move focus back to the toggle button
 when closing the uploader.
                                 .focus();
                 }
         }


 }}}

 Please repair this in future versions.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41231>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list