enketo-core
Version:
Extensible Enketo form engine
18 lines (16 loc) • 550 B
JavaScript
/**
* Update a HTML anchor to serve as a download or reset it if an empty objectUrl is provided.
*
* @static
* @param {HTMLElement} anchor - The anchor element
* @param {string} objectUrl - The objectUrl to download
* @param {string} fileName - The filename of the file
*/
function updateDownloadLink(anchor, objectUrl, fileName) {
anchor.setAttribute('href', objectUrl || '');
anchor.setAttribute('download', fileName || '');
}
// Export as default to facilitate overriding this function.
export default {
updateDownloadLink,
};