isDescriptorDeclaration.cjs 836 B

12345678910111213141516171819202122232425262728
  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. const findNodeUpToRoot = require('./findNodeUpToRoot.cjs');
  5. const typeGuards = require('./typeGuards.cjs');
  6. const atKeywords = require('../reference/atKeywords.cjs');
  7. /** @import { Declaration, Node } from 'postcss' */
  8. /**
  9. * Check whether a declaration is a descriptor one
  10. *
  11. * @param {Declaration} decl
  12. * @returns {boolean}
  13. */
  14. function isDescriptorDeclaration(decl) {
  15. return Boolean(findNodeUpToRoot(decl, isAtRuleSupportingDescriptors));
  16. }
  17. /**
  18. * @param {Node} node
  19. */
  20. function isAtRuleSupportingDescriptors(node) {
  21. return typeGuards.isAtRule(node) && !atKeywords.nestingSupportedAtKeywords.has(node.name.toLowerCase());
  22. }
  23. module.exports = isDescriptorDeclaration;