lineHeight.js 849 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. const parsers = require("../parsers");
  3. module.exports.parse = function parse(v) {
  4. const val = parsers.parseKeyword(v, ["normal"]);
  5. if (val) {
  6. return val;
  7. }
  8. const num = parsers.parseNumber(v, true);
  9. if (num) {
  10. return num;
  11. }
  12. return parsers.parseMeasurement(v, true);
  13. };
  14. module.exports.isValid = function isValid(v) {
  15. if (v === "") {
  16. return true;
  17. }
  18. return typeof module.exports.parse(v) === "string";
  19. };
  20. module.exports.definition = {
  21. set(v) {
  22. v = parsers.prepareValue(v, this._global);
  23. if (parsers.hasVarFunc(v)) {
  24. this._setProperty("font", "");
  25. this._setProperty("line-height", v);
  26. } else {
  27. this._setProperty("line-height", module.exports.parse(v));
  28. }
  29. },
  30. get() {
  31. return this.getPropertyValue("line-height");
  32. },
  33. enumerable: true,
  34. configurable: true
  35. };