WordPress.org

Make WordPress Core

Changeset 20049


Ignore:
Timestamp:
02/29/2012 10:24:46 PM (6 years ago)
Author:
koopersmith
Message:

Theme Customizer: Bind the preview iframe load event when triggering refresh instead of when creating the iframe. see #19910.

The loaded event should only fire when we've actually triggered a refresh. If loaded is bound when the iframe is created, sometimes the blank iframe will fire a 'load' event before a refresh is triggered (this occurred with relative frequency in firefox). By binding the loaded event in the refresh function, we prevent this from occurring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/customize-controls.dev.js

    r20035 r20049  
    1313        initialize: function( params, options ) {
    1414            $.extend( this, options || {} );
     15
     16            this.loaded = $.proxy( this.loaded, this );
    1517
    1618            this.loaderUuid = 0;
     
    5456            this.iframe = api.ensure( params.iframe );
    5557            this.form   = api.ensure( params.form );
     58            this.name   = this.iframe.prop('name');
    5659
    5760            this.container = this.iframe.parent();
     
    8487        },
    8588        loader: function() {
    86             var self = this,
    87                 name;
    88 
    8989            if ( this.loading )
    9090                return this.loading;
    9191
    92             name = this.iframe.prop('name');
    93 
    9492            this.loading = $('<iframe />', {
    95                 name: name + '-loading-' + this.loaderUuid++
     93                name: this.name + '-loading-' + this.loaderUuid++
    9694            }).appendTo( this.container );
    97 
    98             this.loading.one( 'load', function() {
    99                 self.iframe.remove();
    100                 self.iframe = self.loading;
    101                 delete self.loading;
    102                 self.iframe.prop( 'name', name );
    103             });
    10495
    10596            return this.loading;
    10697        },
     98        loaded: function() {
     99            this.iframe.remove();
     100            this.iframe = this.loading;
     101            delete this.loading;
     102            this.iframe.prop( 'name', this.name );
     103        },
    107104        refresh: function() {
     105            this.loader().one( 'load', this.loaded );
     106
    108107            this.submit({
    109108                target: this.loader().prop('name'),
Note: See TracChangeset for help on using the changeset viewer.