style backup: +revokeObjectURL +MIME-type

This commit is contained in:
tophf 2017-04-17 23:28:40 +03:00
parent 1651d52776
commit a2faa9398a

View File

@ -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));
});
});