nextNonCommentNode.js 451 B

1234567891011121314151617181920
  1. 'use strict';
  2. /** @typedef {import('postcss').Node} PostcssNode */
  3. /**
  4. * Get the next non-comment node in a PostCSS AST
  5. * at or after a given node.
  6. *
  7. * @param {PostcssNode | void} startNode
  8. * @returns {PostcssNode | null}
  9. */
  10. module.exports = function nextNonCommentNode(startNode) {
  11. if (!startNode || !startNode.next) return null;
  12. if (startNode.type === 'comment') {
  13. return nextNonCommentNode(startNode.next());
  14. }
  15. return startNode;
  16. };