marginLeft.js 875 B

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