single-file-core 1.6.39 → 1.6.40
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/helper.js +13 -2
- package/package.json +1 -1
package/core/helper.js
CHANGED
|
@@ -126,6 +126,8 @@ const COUNTER_STYLE_CHARACTERS = {
|
|
|
126
126
|
"upper-roman": "IVXLCDM",
|
|
127
127
|
"lower-greek": "αβγδεζηθικλμνξοπρστυφχψω"
|
|
128
128
|
};
|
|
129
|
+
const REGEXP_INFINITE_FEATURE_VALUE = /(\(\s*[a-z-]+\s*(?::|<=?|>=?|=)\s*)(-?)infinity\s*\*\s*1([a-z%]+)/gi;
|
|
130
|
+
const MAX_FINITE_FEATURE_VALUE = "3.40282e38";
|
|
129
131
|
const FULL_WIDTH_OFFSET = 0xFEE0;
|
|
130
132
|
const FULL_WIDTH_SPACE = " ";
|
|
131
133
|
const SINGLE_FILE_UI_ELEMENT_CLASS = "single-file-ui-element";
|
|
@@ -203,6 +205,7 @@ export {
|
|
|
203
205
|
getElementCharacters,
|
|
204
206
|
getPseudoElementCharacters,
|
|
205
207
|
getMarkerCharacters,
|
|
208
|
+
normalizeSerializedCSSText,
|
|
206
209
|
initDoc,
|
|
207
210
|
preProcessDoc,
|
|
208
211
|
postProcessDoc,
|
|
@@ -926,7 +929,7 @@ function getStylesheetsContent(styleSheets, adoptedStyleSheetsCache = new Map())
|
|
|
926
929
|
let cssText = "";
|
|
927
930
|
if (styleSheet && styleSheet.cssRules) {
|
|
928
931
|
for (const cssRule of styleSheet.cssRules) {
|
|
929
|
-
cssText += cssRule
|
|
932
|
+
cssText += getSerializedCSSText(cssRule) + "\n";
|
|
930
933
|
}
|
|
931
934
|
}
|
|
932
935
|
adoptedStyleSheetsCache.set(styleSheet, cssText);
|
|
@@ -1343,6 +1346,14 @@ function markLinkStylesheets(doc, markedElements) {
|
|
|
1343
1346
|
return linkElements;
|
|
1344
1347
|
}
|
|
1345
1348
|
|
|
1349
|
+
function getSerializedCSSText(cssRule) {
|
|
1350
|
+
return normalizeSerializedCSSText(cssRule.cssText);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
function normalizeSerializedCSSText(cssText) {
|
|
1354
|
+
return cssText.replace(REGEXP_INFINITE_FEATURE_VALUE, "$1$2" + MAX_FINITE_FEATURE_VALUE + "$3");
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1346
1357
|
function getStylesheetsData(doc, markedElements) {
|
|
1347
1358
|
if (doc) {
|
|
1348
1359
|
const contents = [];
|
|
@@ -1359,7 +1370,7 @@ function getStylesheetsData(doc, markedElements) {
|
|
|
1359
1370
|
if (!stylesheet || textContentStylesheet != sheetStylesheet) {
|
|
1360
1371
|
styleElement.setAttribute(STYLESHEET_ATTRIBUTE_NAME, styleIndex);
|
|
1361
1372
|
markedElements.push(styleElement);
|
|
1362
|
-
contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(
|
|
1373
|
+
contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(getSerializedCSSText).join("\n");
|
|
1363
1374
|
}
|
|
1364
1375
|
}
|
|
1365
1376
|
// eslint-disable-next-line no-unused-vars
|