fontSize.js 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. "use strict";
  2. const parsers = require("../parsers");
  3. module.exports.parse = function parse(v) {
  4. const val = parsers.parseMeasurement(v, true);
  5. if (val) {
  6. return val;
  7. }
  8. const keywords = [
  9. "xx-small",
  10. "x-small",
  11. "small",
  12. "medium",
  13. "large",
  14. "x-large",
  15. "xx-large",
  16. "xxx-large",
  17. "smaller",
  18. "larger"
  19. ];
  20. return parsers.parseKeyword(v, keywords);
  21. };
  22. module.exports.isValid = function isValid(v) {
  23. if (v === "") {
  24. return true;
  25. }
  26. return typeof module.exports.parse(v) === "string";
  27. };
  28. module.exports.definition = {
  29. set(v) {
  30. v = parsers.prepareValue(v, this._global);
  31. if (parsers.hasVarFunc(v)) {
  32. this._setProperty("font", "");
  33. this._setProperty("font-size", v);
  34. } else {
  35. this._setProperty("font-size", module.exports.parse(v));
  36. }
  37. },
  38. get() {
  39. return this.getPropertyValue("font-size");
  40. },
  41. enumerable: true,
  42. configurable: true
  43. };