Skip to content

Commit

Permalink
chore: Remove Blockly.utils.global (google#6120)
Browse files Browse the repository at this point in the history
The Closure Compiler creates globalThis as a pollyfill.
  • Loading branch information
NeilFraser authored Apr 28, 2022
1 parent 739e5c9 commit b7cd2e1
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 76 deletions.
1 change: 0 additions & 1 deletion core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ const {WorkspaceDragger} = goog.require('Blockly.WorkspaceDragger');
const {WorkspaceSvg, resizeSvgContents} = goog.require('Blockly.WorkspaceSvg');
const {Workspace} = goog.require('Blockly.Workspace');
const {ZoomControls} = goog.require('Blockly.ZoomControls');
const {globalThis} = goog.require('Blockly.utils.global');
const {inject} = goog.require('Blockly.inject');
const {inputTypes} = goog.require('Blockly.inputTypes');
/** @suppress {extraRequire} */
Expand Down
1 change: 0 additions & 1 deletion core/browser_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ goog.module('Blockly.browserEvents');

const Touch = goog.require('Blockly.Touch');
const userAgent = goog.require('Blockly.utils.userAgent');
const {globalThis} = goog.require('Blockly.utils.global');


/**
Expand Down
1 change: 0 additions & 1 deletion core/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ goog.module('Blockly.Touch');

/* eslint-disable-next-line no-unused-vars */
const {Gesture} = goog.requireType('Blockly.Gesture');
const {globalThis} = goog.require('Blockly.utils.global');


/**
Expand Down
2 changes: 0 additions & 2 deletions core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const common = goog.require('Blockly.common');
const deprecation = goog.require('Blockly.utils.deprecation');
const dom = goog.require('Blockly.utils.dom');
const extensions = goog.require('Blockly.Extensions');
const global = goog.require('Blockly.utils.global');
const idGenerator = goog.require('Blockly.utils.idGenerator');
const math = goog.require('Blockly.utils.math');
const object = goog.require('Blockly.utils.object');
Expand Down Expand Up @@ -52,7 +51,6 @@ exports.colour = colourUtils;
exports.Coordinate = Coordinate;
exports.deprecation = deprecation;
exports.dom = dom;
exports.global = global.globalThis;
exports.idGenerator = idGenerator;
exports.KeyCodes = KeyCodes;
exports.math = math;
Expand Down
41 changes: 0 additions & 41 deletions core/utils/global.js

This file was deleted.

5 changes: 2 additions & 3 deletions core/utils/svg_math.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
goog.module('Blockly.utils.svgMath');

const deprecation = goog.require('Blockly.utils.deprecation');
const global = goog.require('Blockly.utils.global');
const style = goog.require('Blockly.utils.style');
const userAgent = goog.require('Blockly.utils.userAgent');
const {Coordinate} = goog.require('Blockly.utils.Coordinate');
Expand Down Expand Up @@ -130,7 +129,7 @@ const is3dSupported = function() {
}
// CC-BY-SA Lorenzo Polidori
// stackoverflow.com/questions/5661671/detecting-transform-translate3d-support
if (!global.globalThis['getComputedStyle']) {
if (!globalThis['getComputedStyle']) {
return false;
}

Expand All @@ -150,7 +149,7 @@ const is3dSupported = function() {
for (const t in transforms) {
if (el.style[t] !== undefined) {
el.style[t] = 'translate3d(1px,1px,1px)';
const computedStyle = global.globalThis['getComputedStyle'](el);
const computedStyle = globalThis['getComputedStyle'](el);
if (!computedStyle) {
// getComputedStyle in Firefox returns null when Blockly is loaded
// inside an iframe with display: none. Returning false and not
Expand Down
2 changes: 0 additions & 2 deletions core/utils/useragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
goog.module('Blockly.utils.userAgent');

const {globalThis} = goog.require('Blockly.utils.global');


/**
* The raw useragent string.
Expand Down
2 changes: 0 additions & 2 deletions core/utils/xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
goog.module('Blockly.utils.xml');

const {globalThis} = goog.require('Blockly.utils.global');


/**
* Namespace for Blockly's XML.
Expand Down
1 change: 0 additions & 1 deletion core/workspace_audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ goog.module('Blockly.WorkspaceAudio');
const userAgent = goog.require('Blockly.utils.userAgent');
/* eslint-disable-next-line no-unused-vars */
const {WorkspaceSvg} = goog.requireType('Blockly.WorkspaceSvg');
const {globalThis} = goog.require('Blockly.utils.global');


/**
Expand Down
1 change: 0 additions & 1 deletion generators/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const objectUtils = goog.require('Blockly.utils.object');
const stringUtils = goog.require('Blockly.utils.string');
const {Block} = goog.requireType('Blockly.Block');
const {Generator} = goog.require('Blockly.Generator');
const {globalThis} = goog.require('Blockly.utils.global');
const {inputTypes} = goog.require('Blockly.inputTypes');
const {Names, NameType} = goog.require('Blockly.Names');
const {Workspace} = goog.requireType('Blockly.Workspace');
Expand Down
5 changes: 2 additions & 3 deletions scripts/gulpfiles/chunks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"chunk": [
"blockly:260",
"blockly:259",
"blocks:10:blockly",
"all:11:blockly",
"all1:11:blockly",
Expand Down Expand Up @@ -57,7 +57,6 @@
"./core/widgetdiv.js",
"./core/clipboard.js",
"./core/contextmenu.js",
"./core/utils/global.js",
"./core/utils/useragent.js",
"./core/utils/svg.js",
"./core/utils/dom.js",
Expand Down Expand Up @@ -229,7 +228,6 @@
"./core/events/events_bubble_open.js",
"./core/procedures.js",
"./core/workspace_svg.js",
"./core/utils/deprecation.js",
"./core/utils/svg_math.js",
"./core/bubble_dragger.js",
"./core/connection_type.js",
Expand All @@ -252,6 +250,7 @@
"./core/utils/parsing.js",
"./core/extensions.js",
"./core/block.js",
"./core/utils/deprecation.js",
"./core/utils/string.js",
"./core/dialog.js",
"./core/utils/xml.js",
Expand Down
5 changes: 0 additions & 5 deletions scripts/migration/renamings.json5
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@
mouseToSvg: {newModule: 'Blockly.utils.browserEvents'},
},
},
{
oldName: 'Blockly.utils.global',
newExport: 'globalThis',
newPath: 'Blockly.utils.global',
},
{
oldName: 'Blockly.utils.IdGenerator',
newName: 'Blockly.utils.idGenerator',
Expand Down
3 changes: 1 addition & 2 deletions scripts/package/node/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ Blockly.setLocale = function (locale) {

// Override textToDomDocument and provide Node.js alternatives to DOMParser and
// XMLSerializer.
const globalThis = Blockly.utils.global;
if (typeof globalThis.document !== 'object') {
const jsdom = require('jsdom/lib/jsdom/living');
globalThis.DOMParser = jsdom.DOMParser;
globalThis.XMLSerializer = jsdom.XMLSerializer;
const xmlDocument = Blockly.utils.xml.textToDomDocument(
`<xml xmlns="${Blockly.utils.xml.NAME_SPACE}"></xml>`);
`<xml xmlns="${Blockly.utils.xml.NAME_SPACE}"></xml>`);
Blockly.utils.xml.setDocument(xmlDocument);
}
Loading

0 comments on commit b7cd2e1

Please sign in to comment.