width.js 698 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. const parsers = require("../parsers");
  3. module.exports.parse = function parse(v) {
  4. const dim = parsers.parseMeasurement(v, true);
  5. if (dim) {
  6. return dim;
  7. }
  8. const keywords = ["auto", "min-content", "max-content", "fit-content"];
  9. return parsers.parseKeyword(v, keywords);
  10. };
  11. module.exports.isValid = function isValid(v) {
  12. if (v === "") {
  13. return true;
  14. }
  15. return typeof module.exports.parse(v) === "string";
  16. };
  17. module.exports.definition = {
  18. set(v) {
  19. v = parsers.prepareValue(v, this._global);
  20. this._setProperty("width", module.exports.parse(v));
  21. },
  22. get() {
  23. return this.getPropertyValue("width");
  24. },
  25. enumerable: true,
  26. configurable: true
  27. };