Skip to content

Commit

Permalink
fix: Add hack to copy accessors to global Blockly namespace object (g…
Browse files Browse the repository at this point in the history
…oogle#5536)

Ugly, but it works.
  • Loading branch information
cpcallen authored Sep 27, 2021
1 parent a598751 commit 06a41de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const {BlockSvg} = goog.require('Blockly.BlockSvg');
const {Blocks} = goog.require('Blockly.blocks');
const {ConnectionType} = goog.require('Blockly.ConnectionType');
const {Cursor} = goog.require('Blockly.Cursor');
const {globalThis} = goog.require('Blockly.utils.global');
/** @suppress {extraRequire} */
goog.require('Blockly.Events.BlockCreate');
/** @suppress {extraRequire} */
Expand Down Expand Up @@ -673,3 +674,20 @@ exports.thrasos = thrasos;
exports.uiPosition = uiPosition;
exports.utils = utils;
exports.zelos = zelos;

// Temporary hack to copy accessor properties from exports to the
// global Blockly object as the routine to copy exports in
// goog.exportPath_ (see closure/goog/base.js) invoked by
// declareLegacyNamespace only copies normal data properties, not
// accessors. This can be removed once all remaining calls to
// declareLegacyNamspace have been removed.
if (globalThis.Blockly && typeof globalThis.Blockly === 'object') {
const descriptors = Object.getOwnPropertyDescriptors(exports);
const accessors = {};
for (const key in descriptors) {
if (descriptors[key].get || descriptors[key].set) {
accessors[key] = descriptors[key];
}
}
Object.defineProperties(globalThis.Blockly, accessors);
}

0 comments on commit 06a41de

Please sign in to comment.