Browse Source

Use DOMContentLoaded event, always try to use a worker so error is thrown

DOMContentLoaded event fires sooner fixing the body-async case.
If the user reqeusts a worker, try to use one even if no path is set
so that a helpful error is shown.
pull/120/head
Ed Sanders 10 years ago
parent
commit
7dea98ebe4
  1. 15
      papaparse.js

15
papaparse.js

@ -156,16 +156,13 @@ @@ -156,16 +156,13 @@
{
AUTO_SCRIPT_PATH = getScriptPath();
// Check if the script was loaded synchronously
if ( document.body )
{
document.body.addEventListener('load', function () {
LOADED_SYNC = true;
}, true);
}
else
{
if ( !document.body ) {
// Body doesn't exist yet, must be synchronous
LOADED_SYNC = true;
} else {
document.addEventListener('DOMContentLoaded', function () {
LOADED_SYNC = true;
}, true);
}
}
@ -175,7 +172,7 @@ @@ -175,7 +172,7 @@
function CsvToJson(_input, _config)
{
var config = IS_WORKER ? _config : copyAndValidateConfig(_config);
var useWorker = config.worker && Papa.WORKERS_SUPPORTED && (Papa.SCRIPT_PATH || AUTO_SCRIPT_PATH);
var useWorker = config.worker && Papa.WORKERS_SUPPORTED;
if (useWorker)
{

Loading…
Cancel
Save