stylelint
Version:
A mighty CSS linter that helps you avoid errors and enforce conventions.
30 lines (22 loc) • 698 B
JavaScript
// NOTICE: This file is generated by Rollup. To modify it,
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
;
const typeGuards = require('./typeGuards.cjs');
/** @import { Node } from 'postcss' */
const STOP = 'STOP';
/**
* Iterates over each node up to the root node.
*
* @param {Node} node
* @param {(node: Node) => void | STOP} callback
* @returns {void}
*/
function eachNodeUpToRoot(node, callback) {
let currentNode = node.parent;
while (currentNode && !typeGuards.isRoot(currentNode)) {
if (callback(currentNode) === STOP) break;
currentNode = currentNode.parent;
}
}
exports.STOP = STOP;
exports.default = eachNodeUpToRoot;