Skip to content

Commit

Permalink
fix: Add missing require for Blockly.utils.object, .Size (google#5427)
Browse files Browse the repository at this point in the history
Some files were using Blockly.utils.object.inherits (or .mixin) without
having imported Blockly.utils.object.

Similarly, trashcan.js tried to use utils.Size as a constructor
instead of importing Size from Blockly.utils.Size.
  • Loading branch information
cpcallen authored Sep 3, 2021
1 parent 24d73be commit c31895d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion core/flyout_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const WorkspaceSvg = goog.require('Blockly.WorkspaceSvg');
const Xml = goog.require('Blockly.Xml');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const object = goog.require('Blockly.utils.object');
const toolbox = goog.require('Blockly.utils.toolbox');
const utils = goog.require('Blockly.utils');
const utilsXml = goog.require('Blockly.utils.xml');
Expand Down Expand Up @@ -155,7 +156,7 @@ const Flyout = function(workspaceOptions) {
*/
this.targetWorkspace = null;
};
utils.object.inherits(Flyout, DeleteArea);
object.inherits(Flyout, DeleteArea);

/**
* Does the flyout automatically close when a block is created?
Expand Down
3 changes: 2 additions & 1 deletion core/renderers/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Theme = goog.requireType('Blockly.Theme');
const colour = goog.require('Blockly.utils.colour');
const connectionTypes = goog.require('Blockly.connectionTypes');
const dom = goog.require('Blockly.utils.dom');
const object = goog.require('Blockly.utils.object');
const svgPaths = goog.require('Blockly.utils.svgPaths');
const userAgent = goog.require('Blockly.utils.userAgent');
const utils = goog.require('Blockly.utils');
Expand Down Expand Up @@ -715,7 +716,7 @@ ConstantProvider.prototype.validatedBlockStyle_ = function(blockStyle) {
// Make a new object with all of the same properties.
const valid = /** @type {!Theme.BlockStyle} */ ({});
if (blockStyle) {
utils.object.mixin(valid, blockStyle);
object.mixin(valid, blockStyle);
}
// Validate required properties.
const parsedColour = utils.parseBlockColour(valid['colourPrimary'] || '#000');
Expand Down
3 changes: 2 additions & 1 deletion core/toolbox/toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const aria = goog.require('Blockly.utils.aria');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const object = goog.require('Blockly.utils.object');
const registry = goog.require('Blockly.registry');
const utils = goog.require('Blockly.utils');
const toolbox = goog.require('Blockly.utils.toolbox');
Expand Down Expand Up @@ -189,7 +190,7 @@ const Toolbox = function(workspace) {
*/
this.boundEvents_ = [];
};
utils.object.inherits(Toolbox, DeleteArea);
object.inherits(Toolbox, DeleteArea);

/**
* Handles the given keyboard shortcut.
Expand Down
7 changes: 4 additions & 3 deletions core/trashcan.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ const IPositionable = goog.requireType('Blockly.IPositionable');
const MetricsManager = goog.requireType('Blockly.MetricsManager');
const Options = goog.require('Blockly.Options');
const Rect = goog.require('Blockly.utils.Rect');
const Size = goog.require('Blockly.utils.Size');
const Svg = goog.require('Blockly.utils.Svg');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const Xml = goog.require('Blockly.Xml');
const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const internalConstants = goog.require('Blockly.internalConstants');
const object = goog.require('Blockly.utils.object');
const registry = goog.require('Blockly.registry');
const toolbox = goog.require('Blockly.utils.toolbox');
const uiPosition = goog.require('Blockly.uiPosition');
const utils = goog.require('Blockly.utils');
/** @suppress {extraRequire} */
goog.require('Blockly.Events.TrashcanOpen');

Expand Down Expand Up @@ -123,7 +124,7 @@ const Trashcan = function(workspace) {
}
this.workspace_.addChangeListener(this.onDelete_.bind(this));
};
utils.object.inherits(Trashcan, DeleteArea);
object.inherits(Trashcan, DeleteArea);

/**
* Width of both the trash can and lid images.
Expand Down Expand Up @@ -453,7 +454,7 @@ Trashcan.prototype.position = function(metrics, savedPositions) {

const height = BODY_HEIGHT + LID_HEIGHT;
const startRect = uiPosition.getStartPositionRect(
cornerPosition, new utils.Size(WIDTH, height), MARGIN_HORIZONTAL,
cornerPosition, new Size(WIDTH, height), MARGIN_HORIZONTAL,
MARGIN_VERTICAL, metrics, this.workspace_);

const verticalPosition = cornerPosition.vertical;
Expand Down
4 changes: 2 additions & 2 deletions core/zoom_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Events = goog.require('Blockly.Events');
/* eslint-disable-next-line no-unused-vars */
const IPositionable = goog.requireType('Blockly.IPositionable');
const Rect = goog.require('Blockly.utils.Rect');
const Size = goog.require('Blockly.utils.Size');
const Svg = goog.require('Blockly.utils.Svg');
const Touch = goog.require('Blockly.Touch');
/* eslint-disable-next-line no-unused-vars */
Expand All @@ -27,7 +28,6 @@ const browserEvents = goog.require('Blockly.browserEvents');
const dom = goog.require('Blockly.utils.dom');
const internalConstants = goog.require('Blockly.internalConstants');
const uiPosition = goog.require('Blockly.uiPosition');
const utils = goog.require('Blockly.utils');
/** @suppress {extraRequire} */
goog.require('Blockly.Events.Click');

Expand Down Expand Up @@ -264,7 +264,7 @@ ZoomControls.prototype.position = function(metrics, savedPositions) {
height += this.LARGE_SPACING_ + this.HEIGHT_;
}
const startRect = uiPosition.getStartPositionRect(
cornerPosition, new utils.Size(this.WIDTH_, height),
cornerPosition, new Size(this.WIDTH_, height),
this.MARGIN_HORIZONTAL_, this.MARGIN_VERTICAL_, metrics, this.workspace_);

const verticalPosition = cornerPosition.vertical;
Expand Down
10 changes: 5 additions & 5 deletions tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c31895d

Please sign in to comment.