mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-18 03:55:32 +00:00
13 lines
452 B
JavaScript
13 lines
452 B
JavaScript
/**
|
|
* Get the source index of a selector, excluding leading whitespace.
|
|
*
|
|
* @param {import('postcss-selector-parser').Selector} node
|
|
*
|
|
* @returns {number}
|
|
*/
|
|
export default function getSelectorSourceIndex(node) {
|
|
// The first child node sourceIndex is the same as the parent sourceIndex without leading whitespace
|
|
// If the node doesn't have any children, use the node sourceIndex instead
|
|
return node.first?.sourceIndex ?? node.sourceIndex;
|
|
}
|