single-file-core 1.0.10 → 1.0.11
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/package.json +1 -1
- package/single-file-core.js +17 -8
package/package.json
CHANGED
package/single-file-core.js
CHANGED
|
@@ -1081,8 +1081,11 @@ class Processor {
|
|
|
1081
1081
|
if (element.tagName == "LINK") {
|
|
1082
1082
|
stylesheet = await ProcessorHelper.resolveLinkStylesheetURLs(element.href, baseURI, options, workStyleElement);
|
|
1083
1083
|
} else {
|
|
1084
|
-
stylesheet = cssTree.parse(element.
|
|
1085
|
-
await ProcessorHelper.resolveImportURLs(stylesheet, baseURI, options, workStyleElement);
|
|
1084
|
+
stylesheet = cssTree.parse(element.textContentcd, { context: "stylesheet", parseCustomProperty: true });
|
|
1085
|
+
const importFound = await ProcessorHelper.resolveImportURLs(stylesheet, baseURI, options, workStyleElement);
|
|
1086
|
+
if (importFound) {
|
|
1087
|
+
stylesheet = cssTree.parse(cssTree.generate(stylesheet), { context: "stylesheet", parseCustomProperty: true });
|
|
1088
|
+
}
|
|
1086
1089
|
}
|
|
1087
1090
|
}
|
|
1088
1091
|
return stylesheet;
|
|
@@ -1685,6 +1688,7 @@ class ProcessorHelper {
|
|
|
1685
1688
|
}
|
|
1686
1689
|
|
|
1687
1690
|
static async resolveImportURLs(stylesheet, baseURI, options, workStylesheet, importedStyleSheets = new Set()) {
|
|
1691
|
+
let importFound;
|
|
1688
1692
|
ProcessorHelper.resolveStylesheetURLs(stylesheet, baseURI, workStylesheet);
|
|
1689
1693
|
const imports = getImportFunctions(stylesheet);
|
|
1690
1694
|
await Promise.all(imports.map(async node => {
|
|
@@ -1708,16 +1712,18 @@ class ProcessorHelper {
|
|
|
1708
1712
|
if (mediaQueryListNode) {
|
|
1709
1713
|
content.data = wrapMediaQuery(content.data, cssTree.generate(mediaQueryListNode));
|
|
1710
1714
|
}
|
|
1711
|
-
const
|
|
1715
|
+
const importedStylesheet = cssTree.parse(content.data, { context: "stylesheet", parseCustomProperty: true });
|
|
1712
1716
|
const ancestorStyleSheets = new Set(importedStyleSheets);
|
|
1713
1717
|
ancestorStyleSheets.add(resourceURL);
|
|
1714
|
-
await ProcessorHelper.resolveImportURLs(
|
|
1715
|
-
for (let keyName of Object.keys(
|
|
1716
|
-
node[keyName] =
|
|
1718
|
+
await ProcessorHelper.resolveImportURLs(importedStylesheet, resourceURL, options, workStylesheet, ancestorStyleSheets);
|
|
1719
|
+
for (let keyName of Object.keys(importedStylesheet)) {
|
|
1720
|
+
node[keyName] = importedStylesheet[keyName];
|
|
1717
1721
|
}
|
|
1722
|
+
importFound = true;
|
|
1718
1723
|
}
|
|
1719
1724
|
}
|
|
1720
1725
|
}));
|
|
1726
|
+
return importFound;
|
|
1721
1727
|
|
|
1722
1728
|
async function getStylesheetContent(resourceURL) {
|
|
1723
1729
|
const content = await util.getContent(resourceURL, {
|
|
@@ -1808,8 +1814,11 @@ class ProcessorHelper {
|
|
|
1808
1814
|
if (content.data && content.data.match(/^<!doctype /i)) {
|
|
1809
1815
|
content.data = "";
|
|
1810
1816
|
}
|
|
1811
|
-
|
|
1812
|
-
await ProcessorHelper.resolveImportURLs(stylesheet, resourceURL, options, workStylesheet);
|
|
1817
|
+
let stylesheet = cssTree.parse(content.data, { context: "stylesheet", parseCustomProperty: true });
|
|
1818
|
+
const importFound = await ProcessorHelper.resolveImportURLs(stylesheet, resourceURL, options, workStylesheet);
|
|
1819
|
+
if (importFound) {
|
|
1820
|
+
stylesheet = cssTree.parse(cssTree.generate(stylesheet), { context: "stylesheet", parseCustomProperty: true });
|
|
1821
|
+
}
|
|
1813
1822
|
return stylesheet;
|
|
1814
1823
|
}
|
|
1815
1824
|
}
|