aboutsummaryrefslogtreecommitdiff
path: root/node_modules/clean-css/lib/writer/helpers.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/clean-css/lib/writer/helpers.js
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/clean-css/lib/writer/helpers.js')
-rw-r--r--node_modules/clean-css/lib/writer/helpers.js34
1 files changed, 26 insertions, 8 deletions
diff --git a/node_modules/clean-css/lib/writer/helpers.js b/node_modules/clean-css/lib/writer/helpers.js
index da13cf6eb..11727402c 100644
--- a/node_modules/clean-css/lib/writer/helpers.js
+++ b/node_modules/clean-css/lib/writer/helpers.js
@@ -1,4 +1,3 @@
-var lineBreak = require('os').EOL;
var emptyCharacter = '';
var Breaks = require('../options/format').Breaks;
@@ -79,7 +78,20 @@ function property(context, tokens, position, lastPropertyAt) {
var store = context.store;
var token = tokens[position];
var isPropertyBlock = token[2][0] == Token.PROPERTY_BLOCK;
- var needsSemicolon = position < lastPropertyAt || isPropertyBlock;
+
+ var needsSemicolon;
+ if ( context.format ) {
+ if ( context.format.semicolonAfterLastProperty || isPropertyBlock ) {
+ needsSemicolon = true;
+ } else if ( position < lastPropertyAt ) {
+ needsSemicolon = true;
+ } else {
+ needsSemicolon = false;
+ }
+ } else {
+ needsSemicolon = position < lastPropertyAt || isPropertyBlock;
+ }
+
var isLast = position === lastPropertyAt;
switch (token[0]) {
@@ -101,6 +113,9 @@ function property(context, tokens, position, lastPropertyAt) {
store(context, colon(context));
value(context, token);
store(context, needsSemicolon ? semicolon(context, Breaks.AfterProperty, isLast) : emptyCharacter);
+ break;
+ case Token.RAW:
+ store(context, token);
}
}
@@ -137,7 +152,7 @@ function openBrace(context, where, needsPrefixSpace) {
context.indentWith = context.format.indentWith.repeat(context.indentBy);
return (needsPrefixSpace && allowsSpace(context, Spaces.BeforeBlockBegins) ? Marker.SPACE : emptyCharacter) +
Marker.OPEN_CURLY_BRACKET +
- (allowsBreak(context, where) ? lineBreak : emptyCharacter) +
+ (allowsBreak(context, where) ? context.format.breakWith : emptyCharacter) +
context.indentWith;
} else {
return Marker.OPEN_CURLY_BRACKET;
@@ -148,10 +163,10 @@ function closeBrace(context, where, beforeBlockEnd, isLast) {
if (context.format) {
context.indentBy -= context.format.indentBy;
context.indentWith = context.format.indentWith.repeat(context.indentBy);
- return (allowsBreak(context, Breaks.AfterProperty) || beforeBlockEnd && allowsBreak(context, Breaks.BeforeBlockEnds) ? lineBreak : emptyCharacter) +
+ return (allowsBreak(context, Breaks.AfterProperty) || beforeBlockEnd && allowsBreak(context, Breaks.BeforeBlockEnds) ? context.format.breakWith : emptyCharacter) +
context.indentWith +
Marker.CLOSE_CURLY_BRACKET +
- (isLast ? emptyCharacter : (allowsBreak(context, where) ? lineBreak : emptyCharacter) + context.indentWith);
+ (isLast ? emptyCharacter : (allowsBreak(context, where) ? context.format.breakWith : emptyCharacter) + context.indentWith);
} else {
return Marker.CLOSE_CURLY_BRACKET;
}
@@ -165,13 +180,13 @@ function colon(context) {
function semicolon(context, where, isLast) {
return context.format ?
- Marker.SEMICOLON + (isLast || !allowsBreak(context, where) ? emptyCharacter : lineBreak + context.indentWith) :
+ Marker.SEMICOLON + (isLast || !allowsBreak(context, where) ? emptyCharacter : context.format.breakWith + context.indentWith) :
Marker.SEMICOLON;
}
function comma(context) {
return context.format ?
- Marker.COMMA + (allowsBreak(context, Breaks.BetweenSelectors) ? lineBreak : emptyCharacter) + context.indentWith :
+ Marker.COMMA + (allowsBreak(context, Breaks.BetweenSelectors) ? context.format.breakWith : emptyCharacter) + context.indentWith :
Marker.COMMA;
}
@@ -204,7 +219,10 @@ function all(context, tokens) {
break;
case Token.COMMENT:
store(context, token);
- store(context, allowsBreak(context, Breaks.AfterComment) ? lineBreak : emptyCharacter);
+ store(context, allowsBreak(context, Breaks.AfterComment) ? context.format.breakWith : emptyCharacter);
+ break;
+ case Token.RAW:
+ store(context, token);
break;
case Token.RULE:
rules(context, token[1]);