isKeyframeSelector.cjs 783 B

1234567891011121314151617181920212223242526272829303132333435
  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 keywords = require('../reference/keywords.cjs');
  5. const HAS_TIMELINE_RANGE = new RegExp(
  6. `^(?:${[...keywords.namedTimelineRangeKeywords.values()].join('|')})\\s+(?:\\d+|\\d*\\.\\d+)%$`,
  7. 'i',
  8. );
  9. /**
  10. * Check whether a string is a keyframe selector.
  11. *
  12. * @param {string} selector
  13. * @returns {boolean}
  14. */
  15. function isKeyframeSelector(selector) {
  16. if (keywords.keyframeSelectorKeywords.has(selector)) {
  17. return true;
  18. }
  19. // Percentages
  20. if (/^(?:\d+|\d*\.\d+)%$/.test(selector)) {
  21. return true;
  22. }
  23. if (HAS_TIMELINE_RANGE.test(selector)) {
  24. return true;
  25. }
  26. return false;
  27. }
  28. module.exports = isKeyframeSelector;