Skip to content

Commit

Permalink
fix(toolbox): use typeof keyword rather than isFunction util to d…
Browse files Browse the repository at this point in the history
…etect if `MouseEvent` object is supported (fix unexpected replacement in 53babd2#diff-0b91602cf047a98c67d6c4edaacbfa7399c8e0d2d4564b83ece8419d144aea84R64)
  • Loading branch information
plainheart committed Feb 16, 2024
1 parent 031a908 commit 385a817
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/component/toolbox/feature/SaveAsImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,8 +41,6 @@ export interface ToolboxSaveAsImageFeatureOption extends ToolboxFeatureOption {
lang?: string[]
}

/* global window, document */

class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {

onclick(ecModel: GlobalModel, api: ExtensionAPI) {
Expand All @@ -61,7 +58,7 @@ class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {
});
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';
Expand Down

0 comments on commit 385a817

Please sign in to comment.