borderBottomStyle.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. const parsers = require("../parsers");
  3. const property = "border-bottom-style";
  4. const lineShorthand = "border-style";
  5. const positionShorthand = "border-bottom";
  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.resolveKeywordValue(value);
  18. } else if (typeof value === "string") {
  19. return value;
  20. }
  21. };
  22. module.exports.definition = {
  23. set(v) {
  24. v = parsers.prepareValue(v);
  25. if (parsers.hasVarFunc(v)) {
  26. this._borderSetter(property, v, "");
  27. } else {
  28. const val = module.exports.parse(v, {
  29. globalObject: this._global
  30. });
  31. if (typeof val === "string") {
  32. const shorthandPriority = this._priorities.get(shorthand);
  33. const linePriority = this._priorities.get(lineShorthand);
  34. const positionPriority = this._priorities.get(positionShorthand);
  35. const priority =
  36. !(shorthandPriority || linePriority || positionPriority) && this._priorities.has(property)
  37. ? this._priorities.get(property)
  38. : "";
  39. this._borderSetter(property, val, priority);
  40. }
  41. }
  42. },
  43. get() {
  44. return this.getPropertyValue(property);
  45. },
  46. enumerable: true,
  47. configurable: true
  48. };
  49. module.exports.property = property;