[wp-trac] [WordPress Trac] #25010: filter options no longer accept HTML text, e.g.,   in media-views.js

WordPress Trac noreply at wordpress.org
Sun Aug 11 00:36:35 UTC 2013


#25010: filter options no longer accept HTML text, e.g.,   in media-views.js
--------------------------+-----------------------------
 Reporter:  dglingren     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  3.6
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 From v3.5.2 to v3.6 the function that creates dropdown option elements has
 changed. The relevant functions are listed below.

 In particular, 3.5.2 code is:

 {{{
 el: this.make( 'option', { value: value }, filter.text ),
 }}}
 and 3.6 code is:

 {{{
 el: $('<option></option>').val(value).text(filter.text)[0],
 }}}

 Using the .text(filter.text) method strips HTML such as non-breaking
 spaces (nbsp) from the text, replacing them with ampersand-nbsp-semicolon.
 This makes it impossible to indent a list.

 Would it be possible to use the .html(filter.text) method instead?

 WordPress 3.6  /wp-includes/js/media-views.js lines 3132 - 3146

 {{{
                 initialize: function() {
                         this.createFilters();
                         _.extend( this.filters, this.options.filters );

                         // Build `<option>` elements.
                         this.$el.html( _.chain( this.filters ).map(
 function( filter, value ) {
                                 return {
                                         el:
 $('<option></option>').val(value).text(filter.text)[0],
                                         priority: filter.priority || 50
                                 };
                         }, this ).sortBy('priority').pluck('el').value()
 );

                         this.model.on( 'change', this.select, this );
                         this.select();
                 },
 }}}


 WordPress 3.5.2 /wp-includes/js/media-views.js lines 3465 - 3483

 {{{
                 initialize: function() {
                         this.createFilters();
                         _.extend( this.filters, this.options.filters );

                         // Build `<option>` elements.
                         this.$el.html( _.chain( this.filters ).map(
 function( filter, value ) {
                                 return {
                                         el: this.make( 'option', { value:
 value }, filter.text ),
                                         priority: filter.priority || 50
                                 };
                         }, this ).sortBy('priority').pluck('el').value()
 );

                         this.model.on( 'change', this.select, this );
                         this.select();
                 },

                 createFilters: function() {
                         this.filters = {};
                 },
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25010>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list