single-file-core 1.6.7 → 1.6.8
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/index.js +8 -5
- package/core/infobar.js +8 -2
- package/modules/css-rules-minifier.js +9 -4
- package/package.json +1 -1
package/core/index.js
CHANGED
|
@@ -435,6 +435,7 @@ const SCRIPT_OPTIONS = "data-single-file-options";
|
|
|
435
435
|
const JAVASCRIPT_URI_PROTOCOL = "javascript:";
|
|
436
436
|
const DISABLED_SCRIPT_URI = "javascript:void(0)";
|
|
437
437
|
const SCRIPT_URI_ATTRIBUTE_NAMES = ["href", "src", "action", "formaction", "data"];
|
|
438
|
+
const SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
|
|
438
439
|
const UTF8_CHARSET = "utf-8";
|
|
439
440
|
const TAINTED_CANVAS_WARNING_MESSAGE = "SingleFile: canvas elements tainted by a cross-origin resource, dropped from the page:";
|
|
440
441
|
const EMPTY_RESOURCE = "data:,";
|
|
@@ -1762,13 +1763,15 @@ function isScriptURI(value) {
|
|
|
1762
1763
|
}
|
|
1763
1764
|
|
|
1764
1765
|
function getOnEventAttributeNames(doc) {
|
|
1765
|
-
const
|
|
1766
|
+
const elements = [doc.body || doc.createElement("div"), doc.createElementNS(SVG_NAMESPACE_URI, "animate")];
|
|
1766
1767
|
const attributeNames = [];
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1768
|
+
elements.forEach(element => {
|
|
1769
|
+
for (const propertyName in element) {
|
|
1770
|
+
if (propertyName.startsWith("on")) {
|
|
1771
|
+
attributeNames.push(propertyName);
|
|
1772
|
+
}
|
|
1770
1773
|
}
|
|
1771
|
-
}
|
|
1774
|
+
});
|
|
1772
1775
|
return attributeNames;
|
|
1773
1776
|
}
|
|
1774
1777
|
|
package/core/infobar.js
CHANGED
|
@@ -157,7 +157,7 @@ const INFOBAR_ANIMATIONS_STYLES = `
|
|
|
157
157
|
animation-iteration-count: 2;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
.infobar
|
|
160
|
+
.infobar::after {
|
|
161
161
|
content: "";
|
|
162
162
|
position: absolute;
|
|
163
163
|
inset: -2px;
|
|
@@ -170,6 +170,12 @@ const INFOBAR_ANIMATIONS_STYLES = `
|
|
|
170
170
|
animation-timing-function: ease-out;
|
|
171
171
|
animation-delay: 2s;
|
|
172
172
|
animation-iteration-count: 3;
|
|
173
|
+
transition: visibility 0s 999999s;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.infobar:focus-within::after, .infobar.infobar-focus::after {
|
|
177
|
+
visibility: hidden;
|
|
178
|
+
transition-delay: 0s;
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
@keyframes flash {
|
|
@@ -194,7 +200,7 @@ const INFOBAR_ANIMATIONS_STYLES = `
|
|
|
194
200
|
|
|
195
201
|
@media (prefers-reduced-motion: reduce) {
|
|
196
202
|
.infobar,
|
|
197
|
-
.infobar
|
|
203
|
+
.infobar::after {
|
|
198
204
|
animation-name: none;
|
|
199
205
|
}
|
|
200
206
|
}
|
|
@@ -58,6 +58,7 @@ const PARSE_CSS_ERROR_MESSAGE = "Failed to parse CSS";
|
|
|
58
58
|
const QSA_ERROR_MESSAGE = "Failed to match selector";
|
|
59
59
|
const PRELUDE_SEPARATOR = ",";
|
|
60
60
|
const NESTING_SELECTOR = "&";
|
|
61
|
+
const SCOPE_PSEUDO_CLASS = ":scope";
|
|
61
62
|
const VENDOR_PREFIX = "-";
|
|
62
63
|
const CUSTOM_PROPERTY_PREFIX = "--";
|
|
63
64
|
const LAYER_NAME_SEPARATOR = ".";
|
|
@@ -388,7 +389,7 @@ function minifyStylesheetRule(ruleData, cssRule, stylesheets, processingContext,
|
|
|
388
389
|
|
|
389
390
|
function processSelectors(ruleData, processingContext, docContext) {
|
|
390
391
|
const removedSelectors = [];
|
|
391
|
-
const { ancestorsSelectors } = processingContext;
|
|
392
|
+
const { ancestorsSelectors, scopeStack } = processingContext;
|
|
392
393
|
for (let selector = ruleData.prelude.children.head, selectorIndex = 0; selector; selector = selector.next, selectorIndex++) {
|
|
393
394
|
const {
|
|
394
395
|
startsWithCombinator,
|
|
@@ -400,7 +401,8 @@ function processSelectors(ruleData, processingContext, docContext) {
|
|
|
400
401
|
}
|
|
401
402
|
registerSelector(selector, ruleData, processingContext, docContext);
|
|
402
403
|
if (!startsWithCombinator || !ancestorsSelectors || !ancestorsSelectors.length) {
|
|
403
|
-
const
|
|
404
|
+
const relativeToScope = startsWithCombinator && Boolean(scopeStack && scopeStack.length);
|
|
405
|
+
const matchedElements = matchElements(selector, ancestorsSelectors, scopeStack, docContext, relativeToScope);
|
|
404
406
|
if (matchedElements.length) {
|
|
405
407
|
if (!hasUnqueryableSelector) {
|
|
406
408
|
updateMatchingSelectors(matchedElements, selector, docContext);
|
|
@@ -580,8 +582,11 @@ function getConditionalStackForSelector(selector, docContext) {
|
|
|
580
582
|
return conditionalStack;
|
|
581
583
|
}
|
|
582
584
|
|
|
583
|
-
function matchElements(selector, ancestorsSelectors, scopeStack, docContext) {
|
|
584
|
-
|
|
585
|
+
function matchElements(selector, ancestorsSelectors, scopeStack, docContext, relativeToScope) {
|
|
586
|
+
let selectorText = createSelectorText(selector, ancestorsSelectors, docContext);
|
|
587
|
+
if (relativeToScope) {
|
|
588
|
+
selectorText = SCOPE_PSEUDO_CLASS + selectorText;
|
|
589
|
+
}
|
|
585
590
|
const cacheKey = createScopeCacheKey(selectorText, scopeStack);
|
|
586
591
|
const cachedNodes = docContext.matchedSelectors.get(cacheKey);
|
|
587
592
|
if (cachedNodes) {
|