Merge pull request #81 from mrvdb/codehighlight

Resolve an edge case where last language has error
This commit is contained in:
Matt Baer 2019-03-06 14:22:53 -05:00 committed by GitHub
commit 2f683e783e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -22,8 +22,12 @@
var sc = document.createElement('script');
sc.src = uri;
sc.async = false; // critical?
// Set callback on last script
if (uris.indexOf(uri) == uris.length-1) {
sc.onload = callback;
// Set callback regardless
// so we're sure it will run if last element had error
// (we only know after loading, so we've had load time already)
sc.onload = callback; sc.onerror = callback;
}
document.head.appendChild(sc);
});