Skip to content

Commit

Permalink
fixup and simplify auto import cases (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 5, 2020
1 parent bfc3a46 commit 3bf22cb
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/features/script-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ systemJSPrototype.createScript = function (url) {
var lastAutoImportUrl, lastAutoImportDeps;
var autoImportCandidates = {};
var systemRegister = systemJSPrototype.register;
var timeoutCnt = 0;
systemJSPrototype.register = function (deps, declare) {
if (hasDocument && document.readyState === 'loading' && typeof deps !== 'string') {
var scripts = document.getElementsByTagName('script');
Expand All @@ -40,17 +39,9 @@ systemJSPrototype.register = function (deps, declare) {
lastAutoImportUrl = url;
lastAutoImportDeps = deps;
autoImportCandidates[url] = [deps, declare];
var loader = this;
// This timeout ensures that if this is a dynamic script injection by SystemJS
// that the auto import will be cleared after the timeout and hence will not
// be auto imported
timeoutCnt++;
setTimeout(function () {
if (autoImportCandidates[url])
loader.import(url);
if (--timeoutCnt === 0 && document.readyState !== 'loading')
autoImportCandidates = {};
});
// if this is already a System load, then the instantiate has already begun
// so this re-import has no consequence
this.import(url);
}
}
else {
Expand Down

0 comments on commit 3bf22cb

Please sign in to comment.