isStandardSyntaxCombinator.cjs 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. /**
  5. * Check whether a combinator is standard
  6. *
  7. * @param {import('postcss-selector-parser').Combinator} node postcss-selector-parser node (of type combinator)
  8. * @returns {boolean} If `true`, the combinator is standard
  9. */
  10. function isStandardSyntaxCombinator(node) {
  11. // if it's not a combinator, then it's not a standard combinator
  12. if (node.type !== 'combinator') {
  13. return false;
  14. }
  15. // Ignore reference combinators like `/deep/`
  16. if (node.value.startsWith('/') || node.value.endsWith('/')) {
  17. return false;
  18. }
  19. // ignore the combinators that are the first or last node in their container
  20. if (node.parent !== undefined && node.parent !== null) {
  21. const parent = node.parent;
  22. if (node === parent.first) {
  23. return false;
  24. }
  25. if (node === parent.last) {
  26. return false;
  27. }
  28. }
  29. return true;
  30. }
  31. module.exports = isStandardSyntaxCombinator;