Skip to content

Commit 706b74b

Browse files
authored
Merge pull request #19620 from apache/fix/toolbox/saveAsImage
fix(toolbox): use `typeof` operator rather than `isFunction` util to detect if `MouseEvent` object is supported
2 parents 031a908 + 385a817 commit 706b74b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/component/toolbox/feature/SaveAsImage.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
* under the License.
1818
*/
1919

20-
/* global Uint8Array, document */
20+
/* global window, Uint8Array, document */
2121

2222
import env from 'zrender/src/core/env';
2323
import { ToolboxFeature, ToolboxFeatureOption } from '../featureManager';
2424
import { ZRColor } from '../../../util/types';
2525
import GlobalModel from '../../../model/Global';
2626
import ExtensionAPI from '../../../core/ExtensionAPI';
27-
import { isFunction } from 'zrender/src/core/util';
2827

2928
export interface ToolboxSaveAsImageFeatureOption extends ToolboxFeatureOption {
3029
icon?: string
@@ -42,8 +41,6 @@ export interface ToolboxSaveAsImageFeatureOption extends ToolboxFeatureOption {
4241
lang?: string[]
4342
}
4443

45-
/* global window, document */
46-
4744
class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {
4845

4946
onclick(ecModel: GlobalModel, api: ExtensionAPI) {
@@ -61,7 +58,7 @@ class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {
6158
});
6259
const browser = env.browser;
6360
// Chrome, Firefox, New Edge
64-
if (isFunction(MouseEvent) && (browser.newEdge || (!browser.ie && !browser.edge))) {
61+
if (typeof MouseEvent === 'function' && (browser.newEdge || (!browser.ie && !browser.edge))) {
6562
const $a = document.createElement('a');
6663
$a.download = title + '.' + type;
6764
$a.target = '_blank';

0 commit comments

Comments
 (0)