borderTop.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. const parsers = require("../parsers");
  3. const borderTopWidth = require("./borderTopWidth");
  4. const borderTopStyle = require("./borderTopStyle");
  5. const borderTopColor = require("./borderTopColor");
  6. const shorthandFor = new Map([
  7. ["border-top-width", borderTopWidth],
  8. ["border-top-style", borderTopStyle],
  9. ["border-top-color", borderTopColor]
  10. ]);
  11. module.exports.definition = {
  12. set(v) {
  13. v = parsers.prepareValue(v, this._global);
  14. if (parsers.hasVarFunc(v)) {
  15. for (const [key] of shorthandFor) {
  16. this._setProperty(key, "");
  17. }
  18. this._setProperty("border", "");
  19. this._setProperty("border-top", v);
  20. } else {
  21. this._shorthandSetter("border-top", v, shorthandFor);
  22. }
  23. },
  24. get() {
  25. let val = this.getPropertyValue("border-top");
  26. if (parsers.hasVarFunc(val)) {
  27. return val;
  28. }
  29. val = this._shorthandGetter("border-top", shorthandFor);
  30. if (parsers.hasVarFunc(val)) {
  31. return "";
  32. }
  33. return val;
  34. },
  35. enumerable: true,
  36. configurable: true
  37. };