Skip to content

Commit

Permalink
tweak node generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Mar 21, 2017
1 parent ed90fc1 commit 1e95877
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
29 changes: 15 additions & 14 deletions lib/syntax/node/AnPlusB.js
Expand Up @@ -152,25 +152,26 @@ module.exports = {
};
},
generate: function(node) {
var result = '';
var a = node.a !== null && node.a !== undefined;
var b = node.b !== null && node.b !== undefined;
var result;

if (a) {
result += node.a === '+1' || node.a === '1' ? 'n' :
node.a === '-1' ? '-n' :
node.a + 'n';
}

if (a && b) {
if (String(node.b).charAt(0) !== '-' &&
String(node.b).charAt(0) !== '+') {
result += '+';
result =
node.a === '+1' || node.a === '1' ? 'n' :
node.a === '-1' ? '-n' :
node.a + 'n';

if (b) {
b = String(node.b);
if (b.charAt(0) === '-' || b.charAt(0) === '+') {
result = [result, b.charAt(0), b.substr(1)];
} else {
result = [result, '+', b];
}
}
}

if (b) {
result += node.b;
} else {
result = String(node.b);
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax/node/AttributeSelector.js
Expand Up @@ -151,7 +151,7 @@ module.exports = {
}

if (node.flags !== null) {
result.push(flagsPrefix + node.flags);
result.push(flagsPrefix, node.flags);
}

result.push(']');
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax/node/Function.js
Expand Up @@ -33,7 +33,7 @@ module.exports = {
};
},
generate: function(node) {
return [].concat(node.name, '(', this.each(node.children), ')');
return [].concat(node.name + '(', this.each(node.children), ')');
},
walkContext: 'function'
};
4 changes: 2 additions & 2 deletions lib/syntax/node/MediaFeature.js
Expand Up @@ -63,7 +63,7 @@ module.exports = {
},
generate: function(node) {
return node.value !== null
? ['(' + node.name + ':', this.generate(node.value), ')']
: '(' + node.name + ')';
? ['(', node.name, ':', this.generate(node.value), ')']
: ['(', node.name, ')'];
}
};
2 changes: 1 addition & 1 deletion lib/syntax/node/Ratio.js
Expand Up @@ -50,6 +50,6 @@ module.exports = {
};
},
generate: function(node) {
return node.left + '/' + node.right;
return [node.left, '/', node.right];
}
};

0 comments on commit 1e95877

Please sign in to comment.