|
|
@@ -1730,19 +1730,14 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
|
|
|
static async processStyle(declarations, baseURI, options, cssVariables, batchRequest) {
|
|
|
await Promise.all(declarations.map(async declaration => {
|
|
|
- let children;
|
|
|
- if (declaration.value) {
|
|
|
- if (declaration.value.children) {
|
|
|
- children = declaration.value.children;
|
|
|
- } else if (declaration.value.type == "Raw") {
|
|
|
- try {
|
|
|
- children = cssTree.parse(declaration.value.value, { context: "value" }).children;
|
|
|
- } catch (error) {
|
|
|
- // ignored
|
|
|
- }
|
|
|
+ if (declaration.value && !declaration.value.children && declaration.value.type == "Raw") {
|
|
|
+ try {
|
|
|
+ declaration.value = cssTree.parse(declaration.value.value, { context: "value" });
|
|
|
+ } catch (error) {
|
|
|
+ // ignored
|
|
|
}
|
|
|
}
|
|
|
- if (declaration.type == "Declaration" && children) {
|
|
|
+ if (declaration.type == "Declaration" && declaration.value.children) {
|
|
|
const urlFunctions = getUrlFunctions(getCSSValue(declaration.value));
|
|
|
await Promise.all(urlFunctions.map(async urlFunction => {
|
|
|
const originalResourceURL = matchURL(urlFunction);
|
|
|
@@ -1752,7 +1747,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
|
|
|
let { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL, true, "image", true);
|
|
|
let variableDefined;
|
|
|
const tokens = [];
|
|
|
- findURLToken(originalResourceURL, children, (token, parent, rootFunction) => {
|
|
|
+ findURLToken(originalResourceURL, declaration.value.children, (token, parent, rootFunction) => {
|
|
|
if (!originalResourceURL.startsWith("#")) {
|
|
|
if (duplicate && options.groupDuplicateImages && rootFunction && util.getContentSize(content) < SINGLE_FILE_VARIABLE_MAX_SIZE) {
|
|
|
const value = cssTree.parse("var(" + SINGLE_FILE_VARIABLE_NAME_PREFIX + indexResource + ")", { context: "value" }).children.head;
|