Make WordPress Core

Changeset 31893


Ignore:
Timestamp:
03/25/2015 11:35:37 PM (11 years ago)
Author:
ocean90
Message:

Customizer: [31885] actually hasn't fixed the SecurityErrors. This one does.

props mattwiebe.
fixes #31687.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r31885 r31893  
    19301930                        this.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() });
    19311931
    1932                         // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios.
    1933                         this.targetWindow.set = function( to ) {
    1934                                 var from = this._value;
    1935 
    1936                                 to = this._setter.apply( this, arguments );
    1937                                 to = this.validate( to );
    1938 
    1939                                 if ( null === to || from === to ) {
    1940                                         return this;
    1941                                 }
    1942 
    1943                                 this._value = to;
    1944                                 this._dirty = true;
    1945 
    1946                                 this.callbacks.fireWith( this, [ to, from ] );
    1947 
    1948                                 return this;
    1949                         };
    1950 
    19511932                        this.run( deferred );
    19521933                },
  • trunk/src/wp-includes/js/customize-base.js

    r30219 r31893  
    539539                        this.add( 'channel', params.channel );
    540540                        this.add( 'url', params.url || '' );
    541                         this.add( 'targetWindow', params.targetWindow || defaultTarget );
    542541                        this.add( 'origin', this.url() ).link( this.url ).setter( function( to ) {
    543542                                return to.replace( /([^:]+:\/\/[^\/]+).*/, '$1' );
    544543                        });
     544
     545                        // first add with no value
     546                        this.add( 'targetWindow', null );
     547                        // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios.
     548                        this.targetWindow.set = function( to ) {
     549                                var from = this._value;
     550
     551                                to = this._setter.apply( this, arguments );
     552                                to = this.validate( to );
     553
     554                                if ( null === to || from === to ) {
     555                                        return this;
     556                                }
     557
     558                                this._value = to;
     559                                this._dirty = true;
     560
     561                                this.callbacks.fireWith( this, [ to, from ] );
     562
     563                                return this;
     564                        };
     565                        // now set it
     566                        this.targetWindow( params.targetWindow || defaultTarget );
     567
    545568
    546569                        // Since we want jQuery to treat the receive function as unique
Note: See TracChangeset for help on using the changeset viewer.