From a2faa9398a00903226d932a6a26157c16c86ca1e Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 17 Apr 2017 23:28:40 +0300 Subject: [PATCH] style backup: +revokeObjectURL +MIME-type --- backup/fileSaveLoad.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index 44aa037b..018b2276 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -252,10 +252,13 @@ $('#file-all-styles').onclick = () => { fetch(url) .then(res => res.blob()) .then(blob => { - const a = document.createElement('a'); - a.setAttribute('download', fileName); - a.setAttribute('href', URL.createObjectURL(blob)); - a.dispatchEvent(new MouseEvent('click')); + const objectURL = URL.createObjectURL(blob); + Object.assign(document.createElement('a'), { + download: fileName, + href: objectURL, + type: 'application/json', + }).dispatchEvent(new MouseEvent('click')); + setTimeout(() => URL.revokeObjectURL(objectURL)); }); });