WordPress.org

Make WordPress Core

Changeset 20517


Ignore:
Timestamp:
04/18/2012 08:25:31 PM (7 years ago)
Author:
koopersmith
Message:

Theme Customizer: Use native postMessage for wp.customize.Messenger. see #19910.

  • Removes use of jquery.postmessage.js
  • Fixes bug where Opera would attempt to use the hash transport and redirect to the dashboard.
  • Fixes bug where multiple postMessage connections could not coexist in a single frame.
Location:
trunk/wp-includes/js
Files:
2 edited

Legend:

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

    r20476 r20517  
    432432
    433433            url = this.add( 'url', url );
    434             this.add( 'targetWindow', targetWindow || null );
     434            this.add( 'targetWindow', targetWindow || window.parent );
    435435            this.add( 'origin', url() ).link( url ).setter( function( to ) {
    436436                return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
     
    439439            this.topics = {};
    440440
    441             $.receiveMessage( $.proxy( this.receive, this ), this.origin() || null );
     441            this.receive = $.proxy( this.receive, this );
     442            $( window ).on( 'message', this.receive );
     443        },
     444
     445        destroy: function() {
     446            $( window ).off( 'message', this.receive );
    442447        },
    443448
     
    445450            var message;
    446451
    447             // @todo: remove, this is done in the postMessage plugin.
    448             // if ( this.origin && event.origin !== this.origin )
    449             //  return;
     452            event = event.originalEvent;
     453
     454            // Check to make sure the origin is valid.
     455            if ( this.origin() && event.origin !== this.origin() )
     456                return;
    450457
    451458            message = JSON.parse( event.data );
     
    464471
    465472            message = JSON.stringify({ id: id, data: data });
    466             $.postMessage( message, this.url(), this.targetWindow() );
     473            this.targetWindow().postMessage( message, this.origin() );
    467474        },
    468475
  • trunk/wp-includes/js/customize-loader.dev.js

    r20488 r20517  
    4444                Loader.open( wpCustomizeLoaderL10n.url + '?' + hash );
    4545
    46             if ( ! hash )
     46            if ( ! hash && ! Loader.supports.history )
    4747                Loader.close();
    4848        },
     
    7979                if ( Loader.supports.history && window.location.href !== src )
    8080                    history.pushState( { customize: src }, '', src );
    81                 else if ( Loader.supports.hashchange && hash )
     81                else if ( ! Loader.supports.history && Loader.supports.hashchange && hash )
    8282                    window.location.hash = hash;
    8383            });
     
    9090            this.element.fadeOut( 200, function() {
    9191                Loader.iframe.remove();
     92                Loader.messenger.destroy();
    9293                Loader.iframe    = null;
    9394                Loader.messenger = null;
Note: See TracChangeset for help on using the changeset viewer.