borderWidth.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. var parsers = require('../parsers');
  3. var parsers = require('../parsers');
  4. var implicitSetter = require('../parsers').implicitSetter;
  5. // the valid border-widths:
  6. var widths = ['thin', 'medium', 'thick'];
  7. module.exports.isValid = function parse(v) {
  8. var length = parsers.parseLength(v);
  9. if (length !== undefined) {
  10. return true;
  11. }
  12. if (typeof v !== 'string') {
  13. return false;
  14. }
  15. if (v === '') {
  16. return true;
  17. }
  18. v = v.toLowerCase();
  19. if (widths.indexOf(v) === -1) {
  20. return false;
  21. }
  22. return true;
  23. };
  24. var isValid = module.exports.isValid;
  25. var parser = function (v) {
  26. var length = parsers.parseLength(v);
  27. if (length !== undefined) {
  28. return length;
  29. }
  30. if (isValid(v)) {
  31. return v.toLowerCase();
  32. }
  33. return undefined;
  34. };
  35. module.exports.definition = {
  36. set: implicitSetter('border', 'width', isValid, parser),
  37. get: function () {
  38. return this.getPropertyValue('border-width');
  39. },
  40. enumerable: true,
  41. configurable: true
  42. };