single-file-core 1.2.421 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/infobar.js CHANGED
@@ -154,7 +154,8 @@ function appendInfobar(doc, options, useShadowRoot) {
154
154
  infoData = options.saveDate;
155
155
  }
156
156
  infoData = infoData || "No info";
157
- const infobarElement = createElement(doc, INFOBAR_TAGNAME, doc.body);
157
+ const parentElement = doc.body.tagName == "BODY" ? doc.body : doc.documentElement;
158
+ const infobarElement = createElement(doc, INFOBAR_TAGNAME, parentElement);
158
159
  let infobarContainer;
159
160
  if (useShadowRoot) {
160
161
  infobarContainer = infobarElement.attachShadow({ mode: "open" });
@@ -210,7 +211,6 @@ function appendInfobar(doc, options, useShadowRoot) {
210
211
  shadowRootContent.appendChild(scriptElement);
211
212
  infobarContainer.innerHTML = shadowRootContent.outerHTML;
212
213
  }
213
- doc.body.appendChild(infobarElement);
214
214
  }
215
215
  }
216
216
 
@@ -77,9 +77,9 @@ function getProcessorHelperClass(utilInstance) {
77
77
  if (element.tagName.toUpperCase() == "LINK") {
78
78
  await this.resolveLinkStylesheetURLs(stylesheetInfo, element, element.href, baseURI, options, workStyleElement, resources, stylesheets);
79
79
  } else {
80
- stylesheets.set({ element }, stylesheetInfo);
81
80
  stylesheetInfo.stylesheet = cssTree.parse(element.textContent, { context: "stylesheet", parseCustomProperty: true });
82
81
  await this.resolveImportURLs(stylesheetInfo, baseURI, options, workStyleElement, resources, stylesheets);
82
+ stylesheets.set({ element }, stylesheetInfo);
83
83
  }
84
84
  } else {
85
85
  if (element.tagName.toUpperCase() == "LINK") {
@@ -92,7 +92,6 @@ function getProcessorHelperClass(utilInstance) {
92
92
 
93
93
  replaceStylesheets(doc, stylesheets, options, resources) {
94
94
  const entries = Array.from(stylesheets);
95
- entries.reverse();
96
95
  for (const [key, stylesheetInfo] of entries) {
97
96
  if (key.urlNode) {
98
97
  const name = "stylesheet_" + resources.stylesheets.size + ".css";
@@ -149,7 +148,6 @@ function getProcessorHelperClass(utilInstance) {
149
148
  scoped,
150
149
  mediaText
151
150
  };
152
- stylesheets.set({ urlNode }, stylesheetInfo);
153
151
  const content = await this.getStylesheetContent(resourceURL, options);
154
152
  stylesheetInfo.url = resourceURL = content.resourceURL;
155
153
  const existingStylesheet = Array.from(stylesheets).find(([, stylesheetInfo]) => stylesheetInfo.resourceURL == resourceURL);
@@ -159,6 +157,7 @@ function getProcessorHelperClass(utilInstance) {
159
157
  content.data = getUpdatedResourceContent(resourceURL, content, options);
160
158
  stylesheetInfo.stylesheet = cssTree.parse(content.data, { context: "stylesheet", parseCustomProperty: true });
161
159
  await this.resolveImportURLs(stylesheetInfo, resourceURL, options, workStylesheet, resources, stylesheets);
160
+ stylesheets.set({ urlNode }, stylesheetInfo);
162
161
  }
163
162
  }
164
163
  }
@@ -178,7 +177,6 @@ function getProcessorHelperClass(utilInstance) {
178
177
  mediaText: stylesheetInfo.mediaText
179
178
  });
180
179
  } else {
181
- stylesheets.set({ element }, stylesheetInfo);
182
180
  const content = await util.getContent(resourceURL, {
183
181
  maxResourceSize: options.maxResourceSize,
184
182
  maxResourceSizeEnabled: options.maxResourceSizeEnabled,
@@ -207,6 +205,7 @@ function getProcessorHelperClass(utilInstance) {
207
205
  content.data = getUpdatedResourceContent(content.resourceURL, content, options);
208
206
  stylesheetInfo.stylesheet = cssTree.parse(content.data, { context: "stylesheet", parseCustomProperty: true });
209
207
  await this.resolveImportURLs(stylesheetInfo, resourceURL, options, workStylesheet, resources, stylesheets);
208
+ stylesheets.set({ element }, stylesheetInfo);
210
209
  }
211
210
  }
212
211
  }
@@ -16900,8 +16900,9 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
16900
16900
  const dontReplaceSlashIfUndefined = dontReplaceSlash === undefined ? true : dontReplaceSlash;
16901
16901
  const urlSuffix = PUBLIC_SUFFIX_LIST.find(urlTopLevelDomainName => url.hostname.endsWith("." + urlTopLevelDomainName) && urlTopLevelDomainName);
16902
16902
  const urlDomainName = urlSuffix ? url.hostname.substring(0, url.hostname.length - urlSuffix.length - 1) : url.hostname;
16903
- let urlSubDomains = urlDomainName.substring(0, urlDomainName.lastIndexOf("."));
16904
- const urlDomain = urlDomainName.substring(urlSubDomains.length + 1);
16903
+ const indexLastDotCharacter = urlDomainName.lastIndexOf(".");
16904
+ let urlSubDomains = urlDomainName.substring(0, indexLastDotCharacter == -1 ? 0 : indexLastDotCharacter);
16905
+ const urlDomain = urlDomainName.substring(urlSubDomains.length ? urlSubDomains.length + 1 : 0);
16905
16906
  const urlRoot = urlDomain + "." + urlSuffix;
16906
16907
  if (urlSubDomains.startsWith("www.")) {
16907
16908
  urlSubDomains = urlSubDomains.substring(4);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.2.421",
3
+ "version": "1.3.1",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",