Make WordPress Core

Changeset 34883


Ignore:
Timestamp:
10/06/2015 09:58:48 PM (9 years ago)
Author:
westonruter
Message:

Customizer: Ensure that wp.customize.Widgets.savedWidgetIds is defined up front.

In 4.3 the widget controls were fully initialized up front along with the sidebar controls. The sidebar control depended (unnecessarily) on the widget control to ensure that wp.customize.Widgets.savedWidgetIds was defined. So after [34563] there could be a situation where the widgets are added/removed from a sidebar before their controls are initialized (if the sidebar section is never expanded), resulting in an error attempting to get a property off of an undefined value. So this change does the right thing and defines savedWidgetIds up front.

Also changes the savedWidgetIds variable type from an array to an object, to match how it is used as a dictionary lookup.

See #33901.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-widgets.js

    r34563 r34883  
    99
    1010    api.Widgets = api.Widgets || {};
     11    api.Widgets.savedWidgetIds = {};
    1112
    1213    // Link settings
     
    524525            var self = this, rememberSavedWidgetId;
    525526
    526             api.Widgets.savedWidgetIds = api.Widgets.savedWidgetIds || [];
    527 
    528527            // Remember saved widgets so we know which to trash (move to inactive widgets sidebar)
    529528            rememberSavedWidgetId = function() {
Note: See TracChangeset for help on using the changeset viewer.