isKeyframeSelector.js 419 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const { keyframeSelectorKeywords } = require('../reference/keywords');
  3. /**
  4. * Check whether a string is a keyframe selector.
  5. *
  6. * @param {string} selector
  7. * @returns {boolean}
  8. */
  9. module.exports = function isKeyframeSelector(selector) {
  10. if (keyframeSelectorKeywords.has(selector)) {
  11. return true;
  12. }
  13. // Percentages
  14. if (/^(?:\d+|\d*\.\d+)%$/.test(selector)) {
  15. return true;
  16. }
  17. return false;
  18. };