[wp-trac] [WordPress Trac] #35866: Multiple refresh requests from Customizer preview cause Uncaught TypeError: this.targetWindow is not a function

WordPress Trac noreply at wordpress.org
Fri Feb 19 01:31:38 UTC 2016


#35866: Multiple refresh requests from Customizer preview cause Uncaught TypeError:
this.targetWindow is not a function
--------------------------+-----------------
 Reporter:  westonruter   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.5
Component:  Customize     |    Version:  3.4
 Severity:  normal        |   Keywords:
  Focuses:  javascript    |
--------------------------+-----------------
 Add a button to the Customizer preview which sends two `refresh` messages
 back-to-back to the pane:

 {{{#!js
 wp.customize.preview.send( 'refresh' );
 wp.customize.preview.send( 'refresh' );
 }}}

 This will also trigger the error.

 > Uncaught TypeError: this.targetWindow is not a function

 This error is occurring specifically in
 `wp.customize.Messenger.prototype.receive()` where it does

 {{{#!js
 if ( ! this.targetWindow() )
         return;
 }}}

 The problem is that when a `refresh` message is received, the
 `wp.customize.PreviewFrame.prototype.destroy()` method will get called
 which does:

 {{{#!js
 delete this.targetWindow;
 }}}

 And so for the second message received, the `this.targetWindow` variable
 will be undefined.

 The simplest fix here is to just make sure that `this.targetWindow` is
 defined before checking its value.

 This was found when testing #27355.

 Note that this won't be relevant once the iframe is loaded with the
 natural URL (#30028).

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


More information about the wp-trac mailing list