borderStyle.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. "use strict";
  2. const parsers = require("../parsers");
  3. module.exports.parse = function parse(v) {
  4. const keywords = [
  5. "none",
  6. "hidden",
  7. "dotted",
  8. "dashed",
  9. "solid",
  10. "double",
  11. "groove",
  12. "ridge",
  13. "inset",
  14. "outset"
  15. ];
  16. return parsers.parseKeyword(v, keywords);
  17. };
  18. module.exports.isValid = function isValid(v) {
  19. if (v === "") {
  20. return true;
  21. }
  22. return typeof module.exports.parse(v) === "string";
  23. };
  24. module.exports.definition = {
  25. set(v) {
  26. v = parsers.prepareValue(v, this._global);
  27. if (/^none$/i.test(v)) {
  28. v = "";
  29. }
  30. if (parsers.hasVarFunc(v)) {
  31. this._setProperty("border", "");
  32. this._setProperty("border-style", v);
  33. return;
  34. }
  35. const positions = ["top", "right", "bottom", "left"];
  36. this._implicitSetter(
  37. "border",
  38. "style",
  39. v,
  40. module.exports.isValid,
  41. module.exports.parse,
  42. positions
  43. );
  44. },
  45. get() {
  46. return this.getPropertyValue("border-style");
  47. },
  48. enumerable: true,
  49. configurable: true
  50. };