Skip to content

Commit

Permalink
Close document after write to fix readystate bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd committed Apr 2, 2014
1 parent 80b79ef commit e217475
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ function(Filer, Async, Log, Content) {

var Path = Filer.Path;

/**
* Open, Write to the document stream, and Close.
*/
function _writeMarkup(markup) {
document.open();
document.write(markup);
document.close();
}

/**
* Given an HTML string, rewrite it with inline resources
*/
Expand Down Expand Up @@ -108,7 +117,7 @@ function(Filer, Async, Log, Content) {
rewriteElements('iframe', 'src', null, callback);
}
], function callback(err, result) {
document.write(doc.documentElement.innerHTML);
_writeMarkup(doc.documentElement.innerHTML);
});
}

Expand Down Expand Up @@ -183,7 +192,7 @@ function(Filer, Async, Log, Content) {
'<hr>' +
'<address>NoHost/0.0.1 (Web) Server</address>' +
'</body></html>';
document.write(html);
_writeMarkup(html);
},

/**
Expand Down Expand Up @@ -227,7 +236,7 @@ function(Filer, Async, Log, Content) {
this.handle404(path);
return;
}
document.write(data);
_writeMarkup(data);
});
},

Expand Down Expand Up @@ -315,7 +324,7 @@ function(Filer, Async, Log, Content) {
rows += row(icon, alt, href, name, entry.modified, entry.size);
});

document.write(header + rows + footer);
_writeMarkup(header + rows + footer);
}

sh.ls(path, function(err, list) {
Expand Down

0 comments on commit e217475

Please sign in to comment.