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