single-file-core 1.5.76 → 1.5.78

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.
@@ -28,8 +28,6 @@ import { sanitizeSelector } from "./css-selector-sanitizer.js";
28
28
 
29
29
  const DEBUG = false;
30
30
 
31
- const CANONICAL_PSEUDO_ELEMENT_NAMES = new Set(["after", "before", "first-letter", "first-line", "placeholder", "selection", "part", "marker"]);
32
- const DYNAMIC_STATE_PSEUDO_CLASSES = new Set(["hover", "focus", "active", "focus-within", "focus-visible", "target", "visited", "link", "target-current"]);
33
31
  const CONDITIONAL_AT_RULE_NAMES = new Set(["media", "supports", "container"]);
34
32
  const RULE_TYPE = "Rule";
35
33
  const AT_RULE_TYPE = "Atrule";
@@ -289,18 +287,15 @@ function processSelectors(ruleData, processingContext, docContext) {
289
287
  for (let selector = ruleData.prelude.children.head, selectorIndex = 0; selector; selector = selector.next, selectorIndex++) {
290
288
  const {
291
289
  startsWithCombinator,
292
- hasPseudoElement,
293
- hasDynamicStatePseudoClass,
290
+ hasPseudo,
294
291
  scopeRelative
295
292
  } = analyzeSelector(selector.data);
296
293
  registerSelector(selector, ruleData, scopeRelative, processingContext, docContext);
297
294
  if (!startsWithCombinator || !ancestorsSelectors || !ancestorsSelectors.length) {
298
295
  const matchedElements = matchElements(selector, ancestorsSelectors, docContext);
299
- if (matchedElements.length) {
300
- if (!hasPseudoElement && !hasDynamicStatePseudoClass) {
301
- updateMatchingSelectors(matchedElements, selector, docContext);
302
- }
303
- } else {
296
+ if (matchedElements.length && !hasPseudo) {
297
+ updateMatchingSelectors(matchedElements, selector, docContext);
298
+ } else if (!matchedElements.length) {
304
299
  removedSelectors.push(selector);
305
300
  }
306
301
  }
@@ -309,20 +304,16 @@ function processSelectors(ruleData, processingContext, docContext) {
309
304
  }
310
305
 
311
306
  function analyzeSelector(selector) {
312
- let hasPseudoElement = false;
313
- let hasDynamicStatePseudoClass = false;
307
+ let hasPseudo = false;
314
308
  let hasNestingOrScope = false;
315
309
  let startsWithCombinator = false;
316
310
  cssTree.walk(selector, {
317
311
  enter(node) {
318
312
  if (node.type === PSEUDO_ELEMENT_SELECTOR_TYPE) {
319
- hasPseudoElement = true;
313
+ hasPseudo = true;
320
314
  } else if (node.type === PSEUDO_CLASS_SELECTOR_TYPE) {
321
- if (CANONICAL_PSEUDO_ELEMENT_NAMES.has(node.name)) {
322
- hasPseudoElement = true;
323
- } else if (DYNAMIC_STATE_PSEUDO_CLASSES.has(node.name)) {
324
- hasDynamicStatePseudoClass = true;
325
- } else if (node.name === SCOPE_NAME) {
315
+ hasPseudo = true;
316
+ if (node.name === SCOPE_NAME) {
326
317
  hasNestingOrScope = true;
327
318
  }
328
319
  } else if (node.type === NESTING_SELECTOR_TYPE) {
@@ -333,7 +324,7 @@ function analyzeSelector(selector) {
333
324
  const firstChild = selector.children.head.data;
334
325
  startsWithCombinator = firstChild && firstChild.type === COMBINATOR_NAME;
335
326
  const scopeRelative = !startsWithCombinator && !hasNestingOrScope;
336
- return { hasPseudoElement, hasDynamicStatePseudoClass, startsWithCombinator, scopeRelative };
327
+ return { hasPseudo, startsWithCombinator, scopeRelative };
337
328
  }
338
329
 
339
330
  function updateMatchingSelectors(matchedElements, selector, docContext) {
@@ -60,6 +60,7 @@ const UNMATCHABLE_PSEUDO_CLASSES = [
60
60
  "focus-visible",
61
61
  "target-current",
62
62
  "enabled",
63
+ "disabled",
63
64
  "read-only",
64
65
  "read-write",
65
66
  "placeholder-shown",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.76",
3
+ "version": "1.5.78",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",