diff --git a/core/block_render_svg.js b/core/block_render_svg.js index 4c3bfb33b..e51e5bf08 100644 --- a/core/block_render_svg.js +++ b/core/block_render_svg.js @@ -339,12 +339,6 @@ Blockly.BlockSvg.prototype.renderFields_ = continue; } - // Force a width re-calculation on IE and Edge to get around the issue - // described in Blockly.Field.getCachedWidth - if (goog.userAgent.IE || goog.userAgent.EDGE) { - field.updateWidth(); - } - if (this.RTL) { cursorX -= field.renderSep + field.renderWidth; root.setAttribute('transform', diff --git a/core/field.js b/core/field.js index 5155877ef..aab0fc8e9 100644 --- a/core/field.js +++ b/core/field.js @@ -351,10 +351,13 @@ Blockly.Field.getCachedWidth = function(textElement) { // Attempt to compute fetch the width of the SVG text element. try { - width = textElement.getComputedTextLength(); + if (goog.userAgent.IE || goog.userAgent.EDGE) { + width = textElement.getBBox().width; + } else { + width = textElement.getComputedTextLength(); + } } catch (e) { - // MSIE 11 and Edge are known to throw "Unexpected call to method or - // property access." if the block is hidden. Instead, use an + // In other cases where we fail to geth the computed text. Instead, use an // approximation and do not cache the result. At some later point in time // when the block is inserted into the visible DOM, this method will be // called again and, at that point in time, will not throw an exception. diff --git a/core/flyout_base.js b/core/flyout_base.js index c99a02208..95d1ab3cd 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -607,14 +607,6 @@ Blockly.Flyout.prototype.createBlock = function(originalBlock) { this.targetWorkspace_.setResizesEnabled(false); try { newBlock = this.placeNewBlock_(originalBlock); - //Force a render on IE and Edge to get around the issue described in - //Blockly.Field.getCachedWidth - if (goog.userAgent.IE || goog.userAgent.EDGE) { - var blocks = newBlock.getDescendants(); - for (var i = blocks.length - 1; i >= 0; i--) { - blocks[i].render(false); - } - } // Close the flyout. Blockly.hideChaff(); } finally { diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 55ed68de8..4899c03ca 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -857,14 +857,6 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) { Blockly.Events.disable(); try { var block = Blockly.Xml.domToBlock(xmlBlock, this); - // Rerender to get around problem with IE and Edge not measuring text - // correctly when it is hidden. - if (goog.userAgent.IE || goog.userAgent.EDGE) { - var blocks = block.getDescendants(); - for (var i = blocks.length - 1; i >= 0; i--) { - blocks[i].render(false); - } - } // Move the duplicate to original position. var blockX = parseInt(xmlBlock.getAttribute('x'), 10); var blockY = parseInt(xmlBlock.getAttribute('y'), 10);