Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#35866 closed defect (bug) (fixed)

Multiple refresh requests from Customizer preview cause Uncaught TypeError: this.targetWindow is not a function

Reported by: westonruter's profile westonruter Owned by: westonruter's profile westonruter
Milestone: 4.5 Priority: normal
Severity: normal Version: 3.4
Component: Customize Keywords: has-patch
Focuses: javascript Cc:


Add a button to the Customizer preview which sends two refresh messages back-to-back to the pane:

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

if ( ! this.targetWindow() )

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

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).

Attachments (1)

35866.0.diff (501 bytes) - added by westonruter 8 years ago.

Download all attachments as: .zip

Change History (3)

8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch added
  • Owner set to westonruter
  • Status changed from new to accepted

#2 @westonruter
8 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 36583:

Customize: Prevent consecutive refresh requests from preview from causing JS error.

Fixes "Uncaught TypeError: this.targetWindow is not a function".

See #27355.
Fixes #35866.

Note: See TracTickets for help on using tickets.