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

Commit

Permalink
fix whenImportsReady
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Jan 16, 2014
1 parent d5dc2f6 commit ae34005
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/HTMLImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,23 @@ function whenImportsReady(callback, doc) {
var loaded = 0, l = imports.length;
function check() {
loaded++;
if (loaded == l) {
callback && callback();
if (loaded == l && callback) {
callback();
}
}
for (var i=0, imp; (i<l) && (imp=imports[i]); i++) {
if (imp.import) {
if (isImportLoaded(imp)) {
check();
} else {
imp.addEventListener('load', check);
}
}
}

function isImportLoaded(link) {
return link.import && (useNative || link.import.__importParsed);
}

// exports
scope.hasNative = hasNative;
scope.useNative = useNative;
Expand Down

0 comments on commit ae34005

Please sign in to comment.