isStop.js 437 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const isCSSLengthUnit = require('./isCSSLengthUnit');
  3. const unit = require('../util/unit');
  4. function isStop(str) {
  5. let stop = !str;
  6. if (!stop) {
  7. const node = unit(str);
  8. if (node) {
  9. if (node.number === 0 || (!isNaN(node.number) && isCSSLengthUnit(node.unit))) {
  10. stop = true;
  11. }
  12. } else {
  13. stop = (/^calc\(\S+\)$/g).test(str);
  14. }
  15. }
  16. return stop;
  17. }
  18. module.exports = isStop;