META-425 fixes json download unresponsive in firefox

This commit is contained in:
Seyi Adebajo 2017-07-13 09:56:40 -07:00
parent ec0b5ac309
commit ed13a4fecf

View File

@ -495,7 +495,22 @@ export default Component.extend({
const href = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(policy))}`;
const download = `${get(this, 'datasetName')}_policy.json`;
const anchor = document.createElement('a');
const anchorParent = document.body;
/**
* Post download housekeeping
*/
const cleanupPostDownload = () => {
anchor.removeEventListener('click', cleanupPostDownload);
anchorParent.removeChild(anchor);
};
Object.assign(anchor, { download, href });
anchor.addEventListener('click', cleanupPostDownload);
// Element needs to be in DOM to receive event in firefox
anchorParent.appendChild(anchor);
anchor.click();
},