[wp-trac] [WordPress Trac] #30225: Customizer controls with same priorities do not sort in order of addition

WordPress Trac noreply at wordpress.org
Sat Nov 1 05:32:00 UTC 2014


#30225: Customizer controls with same priorities do not sort in order of addition
--------------------------+-------------------
 Reporter:  westonruter   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.1
Component:  Customize     |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  javascript    |
--------------------------+-------------------
 The `blogname`, `blogdescription`, and `display_header_text` controls get
 added with the same priority of 10, but they are expected to be rendered
 in the order of creation. This has historically been the case, but with
 the move to a JS-rendered Customizer pane (#28709), the sort order is no
 longer reliable since `Array.sort` is not stable in many browsers, and so
 sorting two controls with the same priority results in an undefined order
 once the sort is complete. The situation is the same for panels and
 sections: their order is not consistent across browsers if identical
 priorities are used.

 In the past, identical priorities were addressed in PHP with logic like
 this in `WP_Customize_Manager::prepare_controls()`:

 {{{#!php
 // Prepare sections.
 // Reversing makes uasort sort by time added when conflicts occur.
 $this->sections = array_reverse( $this->sections );
 uasort( $this->sections, array( $this, '_cmp_priority' ) );
 }}}

 This, however, does not help on the JS side of things. Sort stability
 needs to be implemented in JS.

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


More information about the wp-trac mailing list