From 3b25c514c266f68f6d5b3d34b96a0b0f7fcfc2df Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Fri, 25 Oct 2019 19:14:26 -0400 Subject: [PATCH] Fix warnings related to icons and bubbles (#3308) * Fix warnings related to bubbles. --- core/bubble.js | 6 +++--- core/comment.js | 7 ++++--- core/icon.js | 4 ++-- core/mutator.js | 10 +++++++--- core/warning.js | 5 +++-- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/core/bubble.js b/core/bubble.js index 388e7ceb8..0ec5ad9c6 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -328,7 +328,7 @@ Blockly.Bubble.prototype.isDeletable = function() { * @private */ Blockly.Bubble.prototype.resizeMouseDown_ = function(e) { - this.promote_(); + this.promote(); Blockly.Bubble.unbindDragEvents_(); if (Blockly.utils.isRightButton(e)) { // No right-click. @@ -374,9 +374,9 @@ Blockly.Bubble.prototype.registerResizeEvent = function(callback) { /** * Move this bubble to the top of the stack. * @return {boolean} Whether or not the bubble has been moved. - * @private + * @package */ -Blockly.Bubble.prototype.promote_ = function() { +Blockly.Bubble.prototype.promote = function() { var svgGroup = this.bubbleGroup_.parentNode; if (svgGroup.lastChild !== this.bubbleGroup_) { svgGroup.appendChild(this.bubbleGroup_); diff --git a/core/comment.js b/core/comment.js index 803e1459c..31f3942bc 100644 --- a/core/comment.js +++ b/core/comment.js @@ -241,8 +241,9 @@ Blockly.Comment.prototype.createBubble_ = function() { Blockly.Comment.prototype.createEditableBubble_ = function() { this.bubble_ = new Blockly.Bubble( /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), - this.createEditor_(), this.block_.svgPath_, - this.iconXY_, this.model_.size.width, this.model_.size.height); + this.createEditor_(), this.block_.pathObject.svgPath, + /** @type {!Blockly.utils.Coordinate} */ (this.iconXY_), + this.model_.size.width, this.model_.size.height); // Expose this comment's block's ID on its top-level SVG group. this.bubble_.setSvgId(this.block_.id); this.bubble_.registerResizeEvent(this.onBubbleResize_.bind(this)); @@ -286,7 +287,7 @@ Blockly.Comment.prototype.disposeBubble_ = function() { * @private */ Blockly.Comment.prototype.startEdit_ = function(_e) { - if (this.bubble_.promote_()) { + if (this.bubble_.promote()) { // Since the act of moving this node within the DOM causes a loss of focus, // we need to reapply the focus. this.textarea_.focus(); diff --git a/core/icon.js b/core/icon.js index cd76e888c..bf2c9043a 100644 --- a/core/icon.js +++ b/core/icon.js @@ -174,8 +174,8 @@ Blockly.Icon.prototype.computeIconLocation = function() { /** * Returns the center of the block's icon relative to the surface. - * @return {!Blockly.utils.Coordinate} Object with x and y properties in workspace - * coordinates. + * @return {Blockly.utils.Coordinate} Object with x and y properties in + * workspace coordinates. */ Blockly.Icon.prototype.getIconLocation = function() { return this.iconXY_; diff --git a/core/mutator.js b/core/mutator.js index af5d9e0b9..649e1fe5e 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -257,7 +257,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) { // Create the bubble. this.bubble_ = new Blockly.Bubble( /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), - this.createEditor_(), this.block_.svgPath_, this.iconXY_, null, null); + this.createEditor_(), this.block_.pathObject.svgPath, + /** @type {!Blockly.utils.Coordinate} */ (this.iconXY_), null, null); // Expose this mutator's block's ID on its top-level SVG group. this.bubble_.setSvgId(this.block_.id); var tree = this.workspace_.options.languageTree; @@ -289,9 +290,12 @@ Blockly.Mutator.prototype.setVisible = function(visible) { // Save the initial connections, then listen for further changes. if (this.block_.saveConnections) { var thisMutator = this; - this.block_.saveConnections(this.rootBlock_); + var mutatorBlock = + /** @type {{saveConnections: function(!Blockly.Block)}} */ ( + this.block_); + mutatorBlock.saveConnections(this.rootBlock_); this.sourceListener_ = function() { - thisMutator.block_.saveConnections(thisMutator.rootBlock_); + mutatorBlock.saveConnections(thisMutator.rootBlock_); }; this.block_.workspace.addChangeListener(this.sourceListener_); } diff --git a/core/warning.js b/core/warning.js index e6d3dcc71..fe9f8c4f7 100644 --- a/core/warning.js +++ b/core/warning.js @@ -134,7 +134,8 @@ Blockly.Warning.prototype.createBubble = function() { this.paragraphElement_ = Blockly.Warning.textToDom_(this.getText()); this.bubble_ = new Blockly.Bubble( /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), - this.paragraphElement_, this.block_.svgPath_, this.iconXY_, null, null); + this.paragraphElement_, this.block_.pathObject.svgPath, + /** @type {!Blockly.utils.Coordinate} */ (this.iconXY_), null, null); // Expose this warning's block's ID on its top-level SVG group. this.bubble_.setSvgId(this.block_.id); if (this.block_.RTL) { @@ -171,7 +172,7 @@ Blockly.Warning.prototype.disposeBubble = function() { */ Blockly.Warning.prototype.bodyFocus_ = function(_e) { - this.bubble_.promote_(); + this.bubble_.promote(); }; /**