source: trip-planner-front/node_modules/csso/lib/replace/property/font.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1module.exports = function compressFont(node) {
2 var list = node.children;
3
4 list.eachRight(function(node, item) {
5 if (node.type === 'Identifier') {
6 if (node.name === 'bold') {
7 item.data = {
8 type: 'Number',
9 loc: node.loc,
10 value: '700'
11 };
12 } else if (node.name === 'normal') {
13 var prev = item.prev;
14
15 if (prev && prev.data.type === 'Operator' && prev.data.value === '/') {
16 this.remove(prev);
17 }
18
19 this.remove(item);
20 } else if (node.name === 'medium') {
21 var next = item.next;
22
23 if (!next || next.data.type !== 'Operator') {
24 this.remove(item);
25 }
26 }
27 }
28 });
29
30 // remove redundant spaces
31 list.each(function(node, item) {
32 if (node.type === 'WhiteSpace') {
33 if (!item.prev || !item.next || item.next.data.type === 'WhiteSpace') {
34 this.remove(item);
35 }
36 }
37 });
38
39 if (list.isEmpty()) {
40 list.insert(list.createItem({
41 type: 'Identifier',
42 name: 'normal'
43 }));
44 }
45};
Note: See TracBrowser for help on using the repository browser.