Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
fix for file:/// xhr in Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Dec 16, 2015
1 parent 9b4fcbe commit be03106
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/system-fetch.js
Expand Up @@ -31,9 +31,22 @@

xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200 || (xhr.status == 0 && xhr.responseText)) {
// in Chrome on file:/// URLs, status is 0
if (xhr.status == 0) {
if (xhr.responseText) {
load();
}
else {
// when responseText is empty, wait for load or error event
// to inform if it is a 404 or empty file
xhr.addEventListener('error', error);
xhr.addEventListener('load', load);
}
}
else if (xhr.status === 200) {
load();
} else {
}
else {
error();
}
}
Expand Down

0 comments on commit be03106

Please sign in to comment.