postcss-custom-properties
Advanced tools
Comparing version 9.0.2 to 9.1.1
# Changes to PostCSS Custom Properties | ||
### 9.1.1 (February 20, 2020) | ||
- Fixed: Preserve spaces in multi-part values ([#203](https://github.com/postcss/postcss-custom-properties/pull/203)) | ||
### 9.1.0 (July 15, 2019) | ||
- Added: Support for preserving trailing comments within a declaration. | ||
### 9.0.2 (July 15, 2019) | ||
@@ -4,0 +12,0 @@ |
@@ -279,7 +279,17 @@ 'use strict'; | ||
if (opts.preserve) { | ||
decl.cloneBefore({ | ||
const beforeDecl = decl.cloneBefore({ | ||
value | ||
}); | ||
if (hasTrailingComment(beforeDecl)) { | ||
beforeDecl.raws.value.value = beforeDecl.value.replace(trailingCommentRegExp, '$1'); | ||
beforeDecl.raws.value.raw = beforeDecl.raws.value.value + beforeDecl.raws.value.raw.replace(trailingCommentRegExp, '$2'); | ||
} | ||
} else { | ||
decl.value = value; | ||
if (hasTrailingComment(decl)) { | ||
decl.raws.value.value = decl.value.replace(trailingCommentRegExp, '$1'); | ||
decl.raws.value.raw = decl.raws.value.value + decl.raws.value.raw.replace(trailingCommentRegExp, '$2'); | ||
} | ||
} | ||
@@ -295,4 +305,9 @@ } | ||
const isTransformableDecl = decl => !customPropertyRegExp$1.test(decl.prop) && customPropertiesRegExp.test(decl.value); | ||
const isTransformableDecl = decl => !customPropertyRegExp$1.test(decl.prop) && customPropertiesRegExp.test(decl.value); // whether the declaration has a trailing comment | ||
const hasTrailingComment = decl => 'value' in Object(Object(decl.raws).value) && 'raw' in decl.raws.value && trailingCommentRegExp.test(decl.raws.value.raw); | ||
const trailingCommentRegExp = /^([\W\w]+)(\s*\/\*[\W\w]+?\*\/)$/; | ||
/* Write Custom Properties to CSS File | ||
@@ -398,3 +413,6 @@ /* ========================================================================== */ | ||
return Object.keys(customProperties).reduce((customPropertiesJSON, key) => { | ||
customPropertiesJSON[key] = String(customProperties[key]); | ||
const valueNodes = customProperties[key]; | ||
customPropertiesJSON[key] = valueNodes.map(propertyObject => { | ||
return propertyObject.toString(); | ||
}).join(' '); | ||
return customPropertiesJSON; | ||
@@ -401,0 +419,0 @@ }, {}); |
{ | ||
"name": "postcss-custom-properties", | ||
"version": "9.0.2", | ||
"version": "9.1.1", | ||
"description": "Use Custom Properties Queries in CSS", | ||
@@ -5,0 +5,0 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
115133
708