Skip to content

Commit

Permalink
fix: remove unused or obsolete useragent checks (google#6355)
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-fenichel authored Aug 17, 2022
1 parent 8c9cabf commit aff21b9
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions core/utils/useragent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let rawUserAgent: string;

let isJavaFx: boolean;

let isChrome: boolean;

let isWebKit: boolean;

let isGecko: boolean;
Expand All @@ -35,8 +33,6 @@ let isAndroid: boolean;

let isIPad: boolean;

let isIPod: boolean;

let isIPhone: boolean;

let isMac: boolean;
Expand All @@ -63,7 +59,6 @@ function has(name: string): boolean {
// Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.44
// (KHTML, like Gecko) JavaFX/8.0 Safari/537.44
isJavaFx = has('JavaFX');
isChrome = (has('Chrome') || has('CriOS'));

// Engines. Logic from:
// https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/engine.js
Expand All @@ -78,14 +73,13 @@ isAndroid = has('Android');
const maxTouchPoints =
globalThis['navigator'] && globalThis['navigator']['maxTouchPoints'];
isIPad = has('iPad') || has('Macintosh') && maxTouchPoints > 0;
isIPod = has('iPod');
isIPhone = has('iPhone') && !isIPad && !isIPod;
isIPhone = has('iPhone') && !isIPad;
isMac = has('Macintosh');

// Devices. Logic from:
// https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/device.js
isTablet = isIPad || isAndroid && !has('Mobile') || has('Silk');
isMobile = !isTablet && (isIPod || isIPhone || isAndroid || has('IEMobile'));
isMobile = !isTablet && (isIPhone || isAndroid);
})(globalThis['navigator'] && globalThis['navigator']['userAgent'] || '');

/** @alias Blockly.utils.userAgent.raw */
Expand All @@ -94,12 +88,6 @@ export const raw: string = rawUserAgent;
/** @alias Blockly.utils.userAgent.JavaFx */
export const JavaFx: boolean = isJavaFx;

/** @alias Blockly.utils.userAgent.CHROME */
export const CHROME: boolean = isChrome;

/** @alias Blockly.utils.userAgent.WEBKIT */
export const WEBKIT: boolean = isWebKit;

/** @alias Blockly.utils.userAgent.GECKO */
export const GECKO: boolean = isGecko;

Expand All @@ -108,17 +96,12 @@ export const ANDROID: boolean = isAndroid;

/** @alias Blockly.utils.userAgent.IPAD */
export const IPAD: boolean = isIPad;
/** @alias Blockly.utils.userAgent.IPOD */
export const IPOD: boolean = isIPod;

/** @alias Blockly.utils.userAgent.IPHONE */
export const IPHONE: boolean = isIPhone;

/** @alias Blockly.utils.userAgent.MAC */
export const MAC: boolean = isMac;

/** @alias Blockly.utils.userAgent.TABLET */
export const TABLET: boolean = isTablet;

/** @alias Blockly.utils.userAgent.MOBILE */
export const MOBILE: boolean = isMobile;

0 comments on commit aff21b9

Please sign in to comment.