@internetarchive/lazy-loader-service
Advanced tools
Comparing version 0.0.0-alpha.1 to 0.0.0-alpha.2
@@ -58,7 +58,17 @@ export var BundleType; | ||
return new Promise((resolve, reject) => { | ||
// if multiple requests get made for this script, just stack the onloads | ||
// and onerrors and all the callbacks will be called in-order of being received | ||
const originalOnLoad = script.onload; | ||
script.onload = (e) => { | ||
if (originalOnLoad) { | ||
originalOnLoad(e); | ||
} | ||
script.setAttribute('dynamicImportLoaded', 'true'); | ||
resolve(e); | ||
}; | ||
const originalOnError = script.onerror; | ||
script.onerror = (e) => { | ||
if (originalOnError) { | ||
originalOnError(e); | ||
} | ||
/* istanbul ignore else */ | ||
@@ -65,0 +75,0 @@ if (script.parentNode) { |
{ | ||
"name": "@internetarchive/lazy-loader-service", | ||
"version": "0.0.0-alpha.1", | ||
"version": "0.0.0-alpha.2", | ||
"description": "A small library to lazy load javascript with a Promise", | ||
@@ -5,0 +5,0 @@ "license": "AGPL-3.0-only", |
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://travis-ci.com/internetarchive/iaux-lazy-loader-service.svg?branch=master)](https://travis-ci.com/internetarchive/iaux) [![codecov](https://codecov.io/gh/internetarchive/iaux-lazy-loader-service/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-lazy-loader-service) | ||
[![Build Status](https://travis-ci.com/internetarchive/iaux-lazy-loader-service.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-lazy-loader-service) [![codecov](https://codecov.io/gh/internetarchive/iaux-lazy-loader-service/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-lazy-loader-service) | ||
@@ -3,0 +3,0 @@ # Lazy Loader Service |
@@ -116,3 +116,9 @@ export enum BundleType { | ||
return new Promise((resolve, reject) => { | ||
// if multiple requests get made for this script, just stack the onloads | ||
// and onerrors and all the callbacks will be called in-order of being received | ||
const originalOnLoad: ((ev: Event) => any) | null = script.onload; | ||
script.onload = (e) => { | ||
if (originalOnLoad) { | ||
originalOnLoad(e); | ||
} | ||
script.setAttribute('dynamicImportLoaded', 'true'); | ||
@@ -122,3 +128,8 @@ resolve(e); | ||
const originalOnError: ((error: string | Event) => any) | null = script.onerror; | ||
script.onerror = (e) => { | ||
if (originalOnError) { | ||
originalOnError(e); | ||
} | ||
/* istanbul ignore else */ | ||
@@ -125,0 +136,0 @@ if (script.parentNode) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50692
280