- Fix (npm): Update load-stylesheets to avoid recursion upon CSS loading errors

This commit is contained in:
Brett Zamir
2018-07-18 21:10:05 -07:00
parent 8a4bca4e32
commit 3289131f7c
10 changed files with 20 additions and 16 deletions

View File

@@ -29,8 +29,9 @@ function loadStylesheets(stylesheets, {
const link = document.createElement('link');
return new Promise((resolve, reject) => {
let rej = reject;
if (acceptErrors) {
reject = typeof acceptErrors === 'function' ? error => {
rej = typeof acceptErrors === 'function' ? error => {
acceptErrors({ error, stylesheetURL, options, resolve, reject });
} : resolve;
}
@@ -72,7 +73,7 @@ function loadStylesheets(stylesheets, {
link.href = stylesheetURL;
addLink();
link.addEventListener('error', error => {
reject(error);
rej(error);
});
link.addEventListener('load', () => {
resolve(link);