isUnicodeRangeDescriptor.cjs 754 B

123456789101112131415161718192021222324252627282930
  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 typeGuards = require('./typeGuards.cjs');
  5. const IS_UNICODE_RANGE = /^unicode-range$/i;
  6. const IS_AT_FONT_FACE = /^font-face$/i;
  7. /**
  8. * Check whether a declaration is the `unicode-range` descriptor of an `@font-face` rule.
  9. *
  10. * @param {import('postcss').Declaration} decl
  11. * @returns {boolean}
  12. */
  13. function isUnicodeRangeDescriptor(decl) {
  14. if (!IS_UNICODE_RANGE.test(decl.prop)) {
  15. return false;
  16. }
  17. const parent = decl.parent;
  18. if (!parent || !typeGuards.isAtRule(parent)) {
  19. return false;
  20. }
  21. return IS_AT_FONT_FACE.test(parent.name);
  22. }
  23. module.exports = isUnicodeRangeDescriptor;