From 17064a1c396d392736b10fcd21493d262d98e27c Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Tue, 14 Mar 2023 11:26:38 -0700 Subject: [PATCH] chore: Remove various IE hacks and workarounds (#6781) * chore: Remove IE-specific hacks from flyout_base.ts. * chore: Remove IE hacks from workspace_svg.ts. * chore: Remove IE hacks from css.ts. * chore: Remove IE hacks from xml.ts. * chore: Remove IE hacks from grid.ts. * chore: Remove errant logging from flyout_base.ts. * chore: Remove obsolete comments about IE from bootstrap.js. * chore: Remove reference to IE from README. * chore: Clean up trailing spaces in bootstrap.js. --- README.md | 2 +- core/css.ts | 16 ---------------- core/flyout_base.ts | 20 +------------------- core/grid.ts | 3 +-- core/workspace_svg.ts | 33 +-------------------------------- core/xml.ts | 4 +--- tests/bootstrap.js | 21 ++++++++------------- 7 files changed, 13 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index eacfc8966..a0ab5a8bf 100644 --- a/README.md +++ b/README.md @@ -83,4 +83,4 @@ We typically triage all bugs within 2 working days, which includes adding any ap ## Good to Know * Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs](https://saucelabs.com) -* We support IE11 and test it using [BrowserStack](https://browserstack.com) +* We test browsers using [BrowserStack](https://browserstack.com) diff --git a/core/css.ts b/core/css.ts index ad96f2627..88284a407 100644 --- a/core/css.ts +++ b/core/css.ts @@ -231,16 +231,11 @@ let content = ` } .blocklyDraggable { - /* backup for browsers (e.g. IE11) that don't support grab */ - cursor: url("<<>>/handopen.cur"), auto; cursor: grab; cursor: -webkit-grab; } - /* backup for browsers (e.g. IE11) that don't support grabbing */ .blocklyDragging { - /* backup for browsers (e.g. IE11) that don't support grabbing */ - cursor: url("<<>>/handclosed.cur"), auto; cursor: grabbing; cursor: -webkit-grabbing; } @@ -248,8 +243,6 @@ let content = ` /* Changes cursor on mouse down. Not effective in Firefox because of https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */ .blocklyDraggable:active { - /* backup for browsers (e.g. IE11) that don't support grabbing */ - cursor: url("<<>>/handclosed.cur"), auto; cursor: grabbing; cursor: -webkit-grabbing; } @@ -258,8 +251,6 @@ let content = ` ahead of block during a drag. This way the cursor is still a closed hand. */ .blocklyBlockDragSurface .blocklyDraggable { - /* backup for browsers (e.g. IE11) that don't support grabbing */ - cursor: url("<<>>/handclosed.cur"), auto; cursor: grabbing; cursor: -webkit-grabbing; } @@ -369,13 +360,6 @@ let content = ` box-sizing: border-box; } -/* Edge and IE introduce a close icon when the input value is longer than a - certain length. This affects our sizing calculations of the text input. - Hiding the close icon to avoid that. */ -.blocklyHtmlInput::-ms-clear { - display: none; -} - /* Remove the increase and decrease arrows on the field number editor */ input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button, input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button { diff --git a/core/flyout_base.ts b/core/flyout_base.ts index 646983751..f5a59e425 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -529,14 +529,9 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.svgGroup_?.setAttribute('height', height.toString()); this.workspace_.setCachedParentSvgSize(width, height); - if (this.svgGroup_?.tagName === 'svg') { + if (this.svgGroup_) { const transform = 'translate(' + x + 'px,' + y + 'px)'; dom.setCssTransform(this.svgGroup_, transform); - } else { - // IE and Edge don't support CSS transforms on SVG elements so - // it's important to set the transform on the SVG element itself - const transform = 'translate(' + x + ',' + y + ')'; - this.svgGroup_?.setAttribute('transform', transform); } // Update the scrollbar (if one exists). @@ -603,19 +598,6 @@ export abstract class Flyout extends DeleteArea implements IFlyout { this.layout_(flyoutInfo.contents, flyoutInfo.gaps); - // IE 11 is an incompetent browser that fails to fire mouseout events. - // When the mouse is over the background, deselect all blocks. - function deselectAll(this: Flyout) { - const topBlocks = this.workspace_.getTopBlocks(false); - for (let i = 0, block; block = topBlocks[i]; i++) { - block.removeSelect(); - } - } - - this.listeners_.push(browserEvents.conditionalBind( - (this.svgBackground_ as SVGPathElement), 'pointerover', this, - deselectAll)); - if (this.horizontalLayout) { this.height_ = 0; } else { diff --git a/core/grid.ts b/core/grid.ts index ca84d90d6..8b88fa169 100644 --- a/core/grid.ts +++ b/core/grid.ts @@ -89,8 +89,7 @@ export class Grid { * @internal */ update(scale: number) { - // MSIE freaks if it sees a 0x0 pattern, so set empty patterns to 100x100. - const safeSpacing = this.spacing * scale || 100; + const safeSpacing = this.spacing * scale; this.pattern.setAttribute('width', safeSpacing.toString()); this.pattern.setAttribute('height', safeSpacing.toString()); diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 72e0c3396..5acdf2235 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -1890,39 +1890,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { common.setMainWorkspace(this); // We call e.preventDefault in many event handlers which means we // need to explicitly grab focus (e.g from a textarea) because - // the browser will not do it for us. How to do this is browser - // dependent. - this.setBrowserFocus(); - } - } - - /** Set the workspace to have focus in the browser. */ - private setBrowserFocus() { - // Blur whatever was focused since explicitly grabbing focus below does not - // work in Edge. - // In IE, SVGs can't be blurred or focused. Check to make sure the current - // focus can be blurred before doing so. - // See https://github.com/google/blockly/issues/4440 - if (document.activeElement && - document.activeElement instanceof HTMLElement) { - document.activeElement.blur(); - } - try { - // Focus the workspace SVG - this is for Chrome and Firefox. + // the browser will not do it for us. this.getParentSvg().focus({preventScroll: true}); - } catch (e) { - // IE and Edge do not support focus on SVG elements. When that fails - // above, get the injectionDiv (the workspace's parent) and focus that - // instead. This doesn't work in Chrome. - try { - // In IE11, use setActive (which is IE only) so the page doesn't scroll - // to the workspace gaining focus. - (this.getParentSvg().parentElement as any).setActive(); - } catch (e) { - // setActive support was discontinued in Edge so when that fails, call - // focus instead. - this.getParentSvg().parentElement!.focus({preventScroll: true}); - } } } diff --git a/core/xml.ts b/core/xml.ts index b6f1753f5..534b32536 100644 --- a/core/xml.ts +++ b/core/xml.ts @@ -171,9 +171,7 @@ export function blockToDom(block: Block, opt_noId?: boolean): Element| const element = utilsXml.createElement(block.isShadow() ? 'shadow' : 'block'); element.setAttribute('type', block.type); if (!opt_noId) { - // It's important to use setAttribute here otherwise IE11 won't serialize - // the block's ID when domToText is called. - element.setAttribute('id', block.id); + element.id = block.id; } if (block.mutationToDom) { // Custom data for an advanced block. diff --git a/tests/bootstrap.js b/tests/bootstrap.js index 01bae8c2b..0b422464a 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -20,17 +20,12 @@ * * See tests/playground.html for example usage. * - * Exception: for speed and compatibility reasons, if this is - * script is loaded in Internet Explorer or from a host other than - * localhost, blockly_compressed.js (et al.) will be loaded - * instead. IE 11 doesn't understand modern JavaScript, and - * because of the sequential, non-parallel module loading carried - * out by thedeubg module loader can be painfully tedious over a - * slow network connection. (This can be overridden by the page - * if desired.) - * - * (Note also that this file eschews certain modern JS constructs, - * like template literals, for compatibility with IE 11.) + * Exception: for speed, if this is script is from a host other + * than localhost, blockly_compressed.js (et al.) will be loaded + * instead. Because of the sequential, non-parallel module loading + * carried out by the debug module loader, loading can be painfully + * tedious over a slow network connection. (This can be overridden + * by the page if desired.) * * The bootstrap code will consult a BLOCKLY_BOOTSTRAP_OPTIONS * global variable to determine what to load. This must be set @@ -107,7 +102,7 @@ // the named export corresponding to the mentioned global variable // will be imported. // - // Exception: in compressed mode, the UMD wrapeprs generated by + // Exception: in compressed mode, the UMD wrappers generated by // chunkWrapper() in scripts/gulpfiles/build_tasks.js already pull // out the desired named export - so in that case the entries here // are treated identically to those in namedImports. @@ -155,7 +150,7 @@ // Disable loading of closure/goog/deps.js (which doesn't exist). window.CLOSURE_NO_DEPS = true; // Load the Closure Library's base.js (the only part of the - // libary we use, mainly for goog.require / goog.provide / + // library we use, mainly for goog.require / goog.provide / // goog.module). document.write( ``