|
|
@@ -331,7 +331,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
|
|
|
async run(onloadListener, options) {
|
|
|
- const resourceURLs = Array.from(this.requests.keys());
|
|
|
+ const resourceURLs = [...this.requests.keys()];
|
|
|
let indexResource = 0;
|
|
|
return Promise.all(resourceURLs.map(async requestKey => {
|
|
|
const [resourceURL, asBinary] = JSON.parse(requestKey);
|
|
|
@@ -363,7 +363,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
|
|
|
cancel() {
|
|
|
this.cancelled = true;
|
|
|
- const resourceURLs = Array.from(this.requests.keys());
|
|
|
+ const resourceURLs = [...this.requests.keys()];
|
|
|
resourceURLs.forEach(requestKey => {
|
|
|
const resourceRequests = this.requests.get(requestKey);
|
|
|
resourceRequests.forEach(callbacks => callbacks.reject());
|
|
|
@@ -1066,13 +1066,13 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
|
|
|
async processStylesheets() {
|
|
|
- await Promise.all(Array.from(this.stylesheets, ([, stylesheetInfo]) =>
|
|
|
+ await Promise.all(Array.from(this.stylesheets).map(([, stylesheetInfo]) =>
|
|
|
ProcessorHelper.processStylesheet(stylesheetInfo.stylesheet.children, this.baseURI, this.options, this.cssVariables, this.batchRequest)
|
|
|
));
|
|
|
}
|
|
|
|
|
|
async processStyleAttributes() {
|
|
|
- return Promise.all(Array.from(this.styles, ([, declarationList]) =>
|
|
|
+ return Promise.all(Array.from(this.styles).map(([, declarationList]) =>
|
|
|
ProcessorHelper.processStyle(declarationList.children.toArray(), this.baseURI, this.options, this.cssVariables, this.batchRequest)
|
|
|
));
|
|
|
}
|
|
|
@@ -1105,7 +1105,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
|
|
|
async processScripts() {
|
|
|
- await Promise.all(Array.from(this.doc.querySelectorAll("script[src]"), async scriptElement => {
|
|
|
+ await Promise.all(Array.from(this.doc.querySelectorAll("script[src]")).map(async scriptElement => {
|
|
|
let resourceURL;
|
|
|
const scriptSrc = scriptElement.getAttribute("src");
|
|
|
scriptElement.removeAttribute("src");
|
|
|
@@ -1623,7 +1623,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
|
|
|
static async processAttribute(resourceElements, attributeName, baseURI, options, cssVariables, styles, batchRequest, processDuplicates, removeElementIfMissing) {
|
|
|
- await Promise.all(Array.from(resourceElements, async resourceElement => {
|
|
|
+ await Promise.all(Array.from(resourceElements).map(async resourceElement => {
|
|
|
let resourceURL = resourceElement.getAttribute(attributeName);
|
|
|
resourceURL = Util.normalizeURL(resourceURL);
|
|
|
if (!Util.testIgnoredPath(resourceURL)) {
|
|
|
@@ -1663,7 +1663,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
|
|
|
static async processXLinks(resourceElements, baseURI, options, batchRequest) {
|
|
|
const attributeName = "xlink:href";
|
|
|
- await Promise.all(Array.from(resourceElements, async resourceElement => {
|
|
|
+ await Promise.all(Array.from(resourceElements).map(async resourceElement => {
|
|
|
const originalResourceURL = resourceElement.getAttribute(attributeName);
|
|
|
let resourceURL = Util.normalizeURL(originalResourceURL);
|
|
|
if (Util.testValidPath(resourceURL) && !Util.testIgnoredPath(resourceURL)) {
|
|
|
@@ -1698,7 +1698,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
}
|
|
|
|
|
|
static async processSrcset(resourceElements, attributeName, baseURI, batchRequest) {
|
|
|
- await Promise.all(Array.from(resourceElements, async resourceElement => {
|
|
|
+ await Promise.all(Array.from(resourceElements).map(async resourceElement => {
|
|
|
const srcset = util.parseSrcset(resourceElement.getAttribute(attributeName));
|
|
|
const srcsetValues = await Promise.all(srcset.map(async srcsetValue => {
|
|
|
let resourceURL = Util.normalizeURL(srcsetValue.url);
|