getArguments.js 535 B

12345678910111213141516171819
  1. 'use strict';
  2. /**
  3. * Extracts the arguments of a CSS function or AtRule.
  4. *
  5. * @param {import('postcss-value-parser').ParsedValue | import('postcss-value-parser').FunctionNode} node
  6. * @return {import('postcss-value-parser').Node[][]}
  7. */
  8. module.exports = function getArguments(node) {
  9. /** @type {import('postcss-value-parser').Node[][]} */
  10. const list = [[]];
  11. for (const child of node.nodes) {
  12. if (child.type !== 'div') {
  13. list[list.length - 1].push(child);
  14. } else {
  15. list.push([]);
  16. }
  17. }
  18. return list;
  19. };