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.

41 lines
904 B

  1. 'use strict';
  2. var parsers = require('../parsers');
  3. // <length> <length>? | inherit
  4. // if one, it applies to both horizontal and verical spacing
  5. // if two, the first applies to the horizontal and the second applies to vertical spacing
  6. var parse = function parse(v) {
  7. if (v === '' || v === null) {
  8. return undefined;
  9. }
  10. if (v === 0) {
  11. return '0px';
  12. }
  13. if (v.toLowerCase() === 'inherit') {
  14. return v;
  15. }
  16. var parts = v.split(/\s+/);
  17. if (parts.length !== 1 && parts.length !== 2) {
  18. return undefined;
  19. }
  20. parts.forEach(function(part) {
  21. if (parsers.valueType(part) !== parsers.TYPES.LENGTH) {
  22. return undefined;
  23. }
  24. });
  25. return v;
  26. };
  27. module.exports.definition = {
  28. set: function(v) {
  29. this._setProperty('border-spacing', parse(v));
  30. },
  31. get: function() {
  32. return this.getPropertyValue('border-spacing');
  33. },
  34. enumerable: true,
  35. configurable: true,
  36. };