single-file-core 1.5.53 → 1.5.54
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/modules/css-rules-minifier.js +10 -17
- package/package.json +1 -1
|
@@ -66,6 +66,7 @@ const EMPTY_STRING = "";
|
|
|
66
66
|
const CSS_IMPORTANCE_NOT_IMPORTANT = 0;
|
|
67
67
|
const CSS_IMPORTANCE_IMPORTANT = 1;
|
|
68
68
|
const INVALID_CSS_ESCAPE_TEST = /\\(?![0-9a-fA-F]{1,6}\s|[^0-9a-zA-Z])/;
|
|
69
|
+
const ANONYMOUS_LAYER_PLACEHOLDER = "\u0000";
|
|
69
70
|
|
|
70
71
|
export {
|
|
71
72
|
process
|
|
@@ -125,12 +126,6 @@ function minifyRules(stylesheets, docContext) {
|
|
|
125
126
|
if (!stylesheetInfo.scoped && stylesheetInfo.stylesheet && !key.urlNode) {
|
|
126
127
|
if (hasChildNodes(stylesheetInfo.stylesheet)) {
|
|
127
128
|
const topConditionalStack = stylesheetInfo.mediaText ? [{ name: "media", prelude: stylesheetInfo.mediaText }] : [];
|
|
128
|
-
if (stylesheetInfo.layerName !== undefined) {
|
|
129
|
-
topConditionalStack.push({ name: "layer", prelude: stylesheetInfo.layerName });
|
|
130
|
-
}
|
|
131
|
-
if (stylesheetInfo.supportsCondition !== undefined) {
|
|
132
|
-
topConditionalStack.push({ name: "supports", prelude: stylesheetInfo.supportsCondition });
|
|
133
|
-
}
|
|
134
129
|
minifyStylesheetRules(stylesheetInfo.stylesheet.children, stylesheets, {
|
|
135
130
|
ancestorsSelectors: [],
|
|
136
131
|
layerStack: [],
|
|
@@ -192,13 +187,11 @@ function buildConditionalStack(conditionalStack, ruleData, docContext) {
|
|
|
192
187
|
|
|
193
188
|
function registerLayerDeclaration(layerStack, layerName, conditionalStack, docContext) {
|
|
194
189
|
const fullLayerName = getFullLayerName([...layerStack, layerName]);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
}
|
|
190
|
+
docContext.layerDeclarations.push({
|
|
191
|
+
name: fullLayerName,
|
|
192
|
+
order: docContext.layerDeclarationCounter++,
|
|
193
|
+
conditionalStack: conditionalStack.slice()
|
|
194
|
+
});
|
|
202
195
|
}
|
|
203
196
|
|
|
204
197
|
function minifyStylesheetRules(cssRules, stylesheets, processingContext, docContext) {
|
|
@@ -422,7 +415,7 @@ function collectDeclarationItemsForElement(element, docContext) {
|
|
|
422
415
|
const declarations = cssRule.block.children;
|
|
423
416
|
for (let declaration = declarations.head; declaration; declaration = declaration.next) {
|
|
424
417
|
const { type, value } = declaration.data;
|
|
425
|
-
if (type === DECLARATION_TYPE && value) {
|
|
418
|
+
if (type === DECLARATION_TYPE && value && value.type !== RAW_TYPE) {
|
|
426
419
|
const isRawValue = value.type === RAW_TYPE;
|
|
427
420
|
const isVendorValue = value.type === VALUE_TYPE && hasChildNodes(value) && value.children.head.data.name && value.children.head.data.name.startsWith(VENDOR_PREFIX);
|
|
428
421
|
const isInvalidValue = value.type === VALUE_TYPE && hasChildNodes(value) && value.children.head.data.name && INVALID_CSS_ESCAPE_TEST.test(value.children.head.data.name);
|
|
@@ -636,8 +629,8 @@ function compareDeclarations(declarationA, declarationB, docContext) {
|
|
|
636
629
|
}
|
|
637
630
|
|
|
638
631
|
function compareLayers(layersA, layersB, docContext) {
|
|
639
|
-
const isUnlayeredA = layersA.length === 0
|
|
640
|
-
const isUnlayeredB = layersB.length === 0
|
|
632
|
+
const isUnlayeredA = layersA.length === 0;
|
|
633
|
+
const isUnlayeredB = layersB.length === 0;
|
|
641
634
|
if (isUnlayeredA && isUnlayeredB) {
|
|
642
635
|
return 0;
|
|
643
636
|
}
|
|
@@ -880,7 +873,7 @@ function getPreludeText(prelude, docContext) {
|
|
|
880
873
|
}
|
|
881
874
|
|
|
882
875
|
function getFullLayerName(layers) {
|
|
883
|
-
return layers.
|
|
876
|
+
return layers.map(layerName => layerName === EMPTY_STRING ? ANONYMOUS_LAYER_PLACEHOLDER : layerName).join(LAYER_NAME_SEPARATOR);
|
|
884
877
|
}
|
|
885
878
|
|
|
886
879
|
function parseCss(text, context = SELECTOR_CONTEXT) {
|