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.

31 lines
968 B

4 years ago
  1. function removeItemAndRedundantWhiteSpace(list, item) {
  2. var prev = item.prev;
  3. var next = item.next;
  4. if (next !== null) {
  5. if (next.data.type === 'WhiteSpace' && (prev === null || prev.data.type === 'WhiteSpace')) {
  6. list.remove(next);
  7. }
  8. } else if (prev !== null && prev.data.type === 'WhiteSpace') {
  9. list.remove(prev);
  10. }
  11. list.remove(item);
  12. }
  13. module.exports = function compressBorder(node) {
  14. node.children.each(function(node, item, list) {
  15. if (node.type === 'Identifier' && node.name.toLowerCase() === 'none') {
  16. if (list.head === list.tail) {
  17. // replace `none` for zero when `none` is a single term
  18. item.data = {
  19. type: 'Number',
  20. loc: node.loc,
  21. value: '0'
  22. };
  23. } else {
  24. removeItemAndRedundantWhiteSpace(list, item);
  25. }
  26. }
  27. });
  28. };