getSelectorSourceIndex.cjs 637 B

123456789101112131415161718
  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. * Get the source index of a selector, excluding leading whitespace.
  6. *
  7. * @param {import('postcss-selector-parser').Selector} node
  8. *
  9. * @returns {number}
  10. */
  11. function getSelectorSourceIndex(node) {
  12. // The first child node sourceIndex is the same as the parent sourceIndex without leading whitespace
  13. // If the node doesn't have any children, use the node sourceIndex instead
  14. return node.first?.sourceIndex ?? node.sourceIndex;
  15. }
  16. module.exports = getSelectorSourceIndex;