You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
950 B

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