isContextFunctionalPseudoClass.js 837 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const keywordSets = require('../reference/keywordSets');
  3. /**
  4. * Check whether a node is a context-functional pseudo-class (i.e. either a logical combination
  5. * or a 'aNPlusBOfSNotationPseudoClasses' / tree-structural pseudo-class)
  6. *
  7. * @param {import('postcss-selector-parser').Node} node - postcss-selector-parser node (of type pseudo)
  8. * @return {node is import('postcss-selector-parser').Pseudo} If `true`, the node is a context-functional pseudo-class
  9. */
  10. module.exports = function isContextFunctionalPseudoClass(node) {
  11. if (node.type === 'pseudo') {
  12. const normalisedParentName = node.value.toLowerCase().replace(/:+/, '');
  13. return (
  14. keywordSets.logicalCombinationsPseudoClasses.has(normalisedParentName) ||
  15. keywordSets.aNPlusBOfSNotationPseudoClasses.has(normalisedParentName)
  16. );
  17. }
  18. return false;
  19. };