mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Use Blob api to generate data links in download saver
This should fix crashing on large wikis under chrome see chrome bug: https://code.google.com/p/chromium/issues/detail?id=103234 This should also speed up generating the download html by a couple of seconds it avoids repeatedly marshalling the base64 encoded href string across the sandbox boundary it avoids some time and memory consumed by "large" dom manipulation major remaining delay is in encodeURIComponent TODO: consider using iconv on the server TODO: consider async invocation of regular expressions to avoid client "lockup" Conflicts: core/modules/savers/download.js
This commit is contained in:
parent
becd0f8739
commit
aef8e63cf8
@ -28,7 +28,12 @@ DownloadSaver.prototype.save = function(text) {
|
|||||||
// Set up the link
|
// Set up the link
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
link.setAttribute("target","_blank");
|
link.setAttribute("target","_blank");
|
||||||
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
|
if(Blob != undefined) {
|
||||||
|
var blob = new Blob([encodeURIComponent(text)], {type: "text/html"});
|
||||||
|
link.setAttribute("href", URL.createObjectURL(blob));
|
||||||
|
} else {
|
||||||
|
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
|
||||||
|
}
|
||||||
link.setAttribute("download",filename);
|
link.setAttribute("download",filename);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
|
Loading…
Reference in New Issue
Block a user