borderLeftWidth.js 1.5 KB

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