Skip to content

Commit

Permalink
Fix a bug where calypsoifyGutenberg was undefined (#37900)
Browse files Browse the repository at this point in the history
We tried to reference the global declaration even though it was undefined.

To fix, we reference it directly from the window object, which declares
a variable and sets its value to undefined.
  • Loading branch information
noahtallen authored Nov 23, 2019
1 parent fba86a6 commit 1e25cbf
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* global fullSiteEditing */
/* global calypsoifyGutenberg */

/**
* External dependencies
Expand Down Expand Up @@ -66,6 +65,13 @@ domReady( () => {
// These should go here so that they have any updates that happened while querying for the selector.
let { closeButtonLabel, closeButtonUrl } = fullSiteEditing;

/**
* We have to reference calypsoifyGutenberg off of the window object
* directly to handle the case where it is undefined. Otherwise, the
* variable declariation itself won't exist, causing a runtime error.
*/
const { calypsoifyGutenberg } = window;

// Use wpcom close button/url if they exist.
if ( calypsoifyGutenberg && calypsoifyGutenberg.closeUrl ) {
closeButtonUrl = calypsoifyGutenberg.closeUrl;
Expand Down

0 comments on commit 1e25cbf

Please sign in to comment.