paddingBottom.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. const parsers = require("../parsers");
  3. const property = "padding-bottom";
  4. const shorthand = "padding";
  5. module.exports.position = "bottom";
  6. module.exports.parse = (v, opt = {}) => {
  7. const { globalObject } = opt;
  8. if (v === "") {
  9. return v;
  10. }
  11. const value = parsers.parsePropertyValue(property, v, {
  12. globalObject,
  13. inArray: true
  14. });
  15. if (Array.isArray(value) && value.length === 1) {
  16. return parsers.resolveNumericValue(value, {
  17. min: 0,
  18. type: "length"
  19. });
  20. } else if (typeof value === "string") {
  21. return value;
  22. }
  23. };
  24. module.exports.definition = {
  25. set(v) {
  26. v = parsers.prepareValue(v);
  27. if (parsers.hasVarFunc(v)) {
  28. this._setProperty(shorthand, "");
  29. this._setProperty(property, v);
  30. } else {
  31. const val = module.exports.parse(v, {
  32. globalObject: this._global
  33. });
  34. if (typeof val === "string") {
  35. const priority =
  36. !this._priorities.get(shorthand) && this._priorities.has(property)
  37. ? this._priorities.get(property)
  38. : "";
  39. this._positionLonghandSetter(property, val, priority, shorthand);
  40. }
  41. }
  42. },
  43. get() {
  44. return this.getPropertyValue(property);
  45. },
  46. enumerable: true,
  47. configurable: true
  48. };
  49. module.exports.property = property;