border.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. var shorthandParser = require('../parsers').shorthandParser;
  3. var shorthandSetter = require('../parsers').shorthandSetter;
  4. var shorthandGetter = require('../parsers').shorthandGetter;
  5. var shorthand_for = {
  6. 'border-width': require('./borderWidth'),
  7. 'border-style': require('./borderStyle'),
  8. 'border-color': require('./borderColor')
  9. };
  10. var isValid = function isValid(v) {
  11. return shorthandParser(v, shorthand_for) !== undefined;
  12. };
  13. module.exports.isValid = isValid;
  14. var parser = function (v) {
  15. if (v.toString().toLowerCase() === 'none') {
  16. v = '';
  17. }
  18. if (isValid(v)) {
  19. return v;
  20. }
  21. return undefined;
  22. };
  23. var myShorthandSetter = shorthandSetter('border', shorthand_for);
  24. var myShorthandGetter = shorthandGetter('border', shorthand_for);
  25. module.exports.definition = {
  26. set: function (v) {
  27. if (v.toString().toLowerCase() === 'none') {
  28. v = '';
  29. }
  30. myShorthandSetter.call(this, v);
  31. this.removeProperty('border-top');
  32. this.removeProperty('border-left');
  33. this.removeProperty('border-right');
  34. this.removeProperty('border-bottom');
  35. this._values['border-top'] = this._values.border;
  36. this._values['border-left'] = this._values.border;
  37. this._values['border-right'] = this._values.border;
  38. this._values['border-bottom'] = this._values.border;
  39. },
  40. get: myShorthandGetter,
  41. enumerable: true,
  42. configurable: true
  43. };