From 385a817ca1e4fb516bf86f00c77722725b357215 Mon Sep 17 00:00:00 2001 From: plainheart Date: Fri, 16 Feb 2024 20:53:33 +0800 Subject: [PATCH] fix(toolbox): use `typeof` keyword rather than `isFunction` util to detect if `MouseEvent` object is supported (fix unexpected replacement in https://github.com/apache/echarts/commit/53babd2b4c83e875f8df6c370b356d6b44c1919c#diff-0b91602cf047a98c67d6c4edaacbfa7399c8e0d2d4564b83ece8419d144aea84R64) --- src/component/toolbox/feature/SaveAsImage.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/component/toolbox/feature/SaveAsImage.ts b/src/component/toolbox/feature/SaveAsImage.ts index 8777a97891..b40c9fdbc8 100644 --- a/src/component/toolbox/feature/SaveAsImage.ts +++ b/src/component/toolbox/feature/SaveAsImage.ts @@ -17,14 +17,13 @@ * under the License. */ -/* global Uint8Array, document */ +/* global window, Uint8Array, document */ import env from 'zrender/src/core/env'; import { ToolboxFeature, ToolboxFeatureOption } from '../featureManager'; import { ZRColor } from '../../../util/types'; import GlobalModel from '../../../model/Global'; import ExtensionAPI from '../../../core/ExtensionAPI'; -import { isFunction } from 'zrender/src/core/util'; export interface ToolboxSaveAsImageFeatureOption extends ToolboxFeatureOption { icon?: string @@ -42,8 +41,6 @@ export interface ToolboxSaveAsImageFeatureOption extends ToolboxFeatureOption { lang?: string[] } -/* global window, document */ - class SaveAsImage extends ToolboxFeature { onclick(ecModel: GlobalModel, api: ExtensionAPI) { @@ -61,7 +58,7 @@ class SaveAsImage extends ToolboxFeature { }); const browser = env.browser; // Chrome, Firefox, New Edge - if (isFunction(MouseEvent) && (browser.newEdge || (!browser.ie && !browser.edge))) { + if (typeof MouseEvent === 'function' && (browser.newEdge || (!browser.ie && !browser.edge))) { const $a = document.createElement('a'); $a.download = title + '.' + type; $a.target = '_blank';