This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fc17cc  fix(SaveAsImage): don't create an anchor element if you don't 
need to
     new afdc82c  Merge pull request #10132 from CarterLi/master
7fc17cc is described below

commit 7fc17cc9e4c16639776de27cb55b9930eace92da
Author: 李通洲 <[email protected]>
AuthorDate: Tue Mar 19 20:14:02 2019 +0800

    fix(SaveAsImage): don't create an anchor element if you don't need to
---
 src/component/toolbox/feature/SaveAsImage.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/component/toolbox/feature/SaveAsImage.js 
b/src/component/toolbox/feature/SaveAsImage.js
index d55c019..0b18aab 100644
--- a/src/component/toolbox/feature/SaveAsImage.js
+++ b/src/component/toolbox/feature/SaveAsImage.js
@@ -49,10 +49,7 @@ var proto = SaveAsImage.prototype;
 proto.onclick = function (ecModel, api) {
     var model = this.model;
     var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
-    var $a = document.createElement('a');
     var type = model.get('type', true) || 'png';
-    $a.download = title + '.' + type;
-    $a.target = '_blank';
     var url = api.getConnectedDataURL({
         type: type,
         backgroundColor: model.get('backgroundColor', true)
@@ -60,9 +57,12 @@ proto.onclick = function (ecModel, api) {
         excludeComponents: model.get('excludeComponents'),
         pixelRatio: model.get('pixelRatio')
     });
-    $a.href = url;
     // Chrome and Firefox
     if (typeof MouseEvent === 'function' && !env.browser.ie && 
!env.browser.edge) {
+        var $a = document.createElement('a');
+        $a.download = title + '.' + type;
+        $a.target = '_blank';
+        $a.href = url;
         var evt = new MouseEvent('click', {
             view: window,
             bubbles: true,
@@ -98,4 +98,4 @@ featureManager.register(
     'saveAsImage', SaveAsImage
 );
 
-export default SaveAsImage;
\ No newline at end of file
+export default SaveAsImage;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to