chore: Remove Blockly.utils.global (#6120)

The Closure Compiler creates globalThis as a pollyfill.
This commit is contained in:
Neil Fraser
2022-04-28 12:39:52 -07:00
committed by GitHub
parent 739e5c9e0e
commit b7cd2e187b
14 changed files with 15 additions and 76 deletions

View File

@@ -1,41 +0,0 @@
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Provides a reference to the global object.
*/
'use strict';
/**
* Provides a reference to the global object.
* @namespace Blockly.utils.global
*/
goog.module('Blockly.utils.global');
/* eslint-disable no-undef, no-invalid-this */
/**
* Reference to the global object.
*
* More info on this implementation here:
* https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI
*/
exports.globalThis = (function() { // Not "let globalThis" to avoid shadowing.
if (typeof globalThis === 'object') {
return globalThis;
}
if (typeof self === 'object') {
return self;
}
if (typeof window === 'object') {
return window;
}
if (typeof global === 'object') {
return global;
}
return this;
})();

View File

@@ -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');
@@ -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;
}
@@ -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

View File

@@ -19,8 +19,6 @@
*/
goog.module('Blockly.utils.userAgent');
const {globalThis} = goog.require('Blockly.utils.global');
/**
* The raw useragent string.

View File

@@ -19,8 +19,6 @@
*/
goog.module('Blockly.utils.xml');
const {globalThis} = goog.require('Blockly.utils.global');
/**
* Namespace for Blockly's XML.