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: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | Customize | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
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() ) return;
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).
In 36583: