diff --git a/src/script.js b/src/script.js index ab0f53c..cb9b585 100644 --- a/src/script.js +++ b/src/script.js @@ -51,8 +51,7 @@ path = !force && path.indexOf('.js') === -1 && !/^https?:\/\//.test(path) && scriptpath ? scriptpath + path + '.js' : path if (scripts[path]) { if (id) ids[id] = 1 - if (scripts[path] == 2) callback() - else return setTimeout(function () { loading(path, true) }, 0) + return (scripts[path] == 2) ? callback() : setTimeout(function () { loading(path, true) }, 0) } scripts[path] = 1 diff --git a/tests/tests.js b/tests/tests.js index 23de0f0..b7078e1 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -133,6 +133,14 @@ script('../node_modules/domready/ready.js', function () { script('double-load', load) }) + test('correctly count loaded scripts', function (done){ + script.path('../vendor/') + script(['patha', 'pathb', 'http://ded.github.com/morpheus/morpheus.js', 'http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js'], function () { + ok(typeof angular !== 'undefined', 'loaded angular.js from http') + done(); + }) + }) + }) start() })