From 579268d428abdebceb3ec083d771eb333b9d05db Mon Sep 17 00:00:00 2001 From: hys Date: Thu, 1 Mar 2018 15:11:24 +0800 Subject: [PATCH] support load error detect --- src/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/script.js b/src/script.js index e3fdfb7..7760000 100644 --- a/src/script.js +++ b/src/script.js @@ -37,10 +37,10 @@ function loopFn(item) { return item.call ? item() : list[item] } - function callback() { + function callback(event) { if (!--queue) { list[id] = 1 - done && done() + done && done(event) for (var dset in delay) { every(dset.split('|'), loopFn) && !each(delay[dset], loopFn) && (delay[dset] = []) } @@ -69,12 +69,12 @@ function create(path, fn) { var el = doc.createElement('script'), loaded - el.onload = el.onerror = el[onreadystatechange] = function () { + el.onload = el.onerror = el[onreadystatechange] = function (event) { if ((el[readyState] && !(/^c|loade/.test(el[readyState]))) || loaded) return; el.onload = el[onreadystatechange] = null loaded = 1 scripts[path] = 2 - fn() + fn(event) } el.async = 1 el.src = urlArgs ? path + (path.indexOf('?') === -1 ? '?' : '&') + urlArgs : path;