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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Aug 28, 2014
1 parent 610e1c4 commit e1bb8e8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ function whenDocumentReady(callback, doc) {
doc.removeEventListener(READY_EVENT, checkReady);
whenDocumentReady(callback, doc);
}
}
};
doc.addEventListener(READY_EVENT, checkReady);
} else if (callback) {
callback();
}
}

function markTargetLoaded(event) {
event.target.__loaded = true;
}

// call <callback> when we ensure all imports have loaded
function watchImportsLoad(callback, doc) {
var imports = doc.querySelectorAll('link[rel=import]');
Expand All @@ -85,13 +89,14 @@ function watchImportsLoad(callback, doc) {
}
}
function loadedImport(e) {
markTargetLoaded(e);
loaded++;
checkDone();
}
if (l) {
for (var i=0, imp; (i<l) && (imp=imports[i]); i++) {
if (isImportLoaded(imp)) {
loadedImport.call(imp);
loadedImport.call(imp, {target: imp});
} else {
imp.addEventListener('load', loadedImport);
imp.addEventListener('error', loadedImport);
Expand Down Expand Up @@ -142,10 +147,6 @@ if (useNative) {
}
}

function markTargetLoaded(event) {
event.target.__loaded = true;
}

}

// Fire the 'HTMLImportsLoaded' event when imports in document at load time
Expand Down

0 comments on commit e1bb8e8

Please sign in to comment.