Socket
Socket
Sign inDemoInstall

postcss-custom-properties

Package Overview
Dependencies
7
Maintainers
3
Versions
85
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.1 to 8.0.2

4

CHANGELOG.md
# Changes to PostCSS Custom Properties
### 8.0.2 (September 17, 2018)
- Fixed: Spacing is preserved before replaced variables.
### 8.0.1 (September 17, 2018)

@@ -4,0 +8,0 @@

36

index.cjs.js

@@ -155,16 +155,8 @@ 'use strict';

// conditionally replace a known custom property
child.replaceWith(...asClonedArray(customProperties[name], null));
const nextCustomProperties = Object.assign({}, customProperties);
delete nextCustomProperties[name];
transformValueAST(root, nextCustomProperties);
child.replaceWith(...asClonedArrayWithBeforeSpacing(customProperties[name], child.raws.before));
retransformValueAST(root, customProperties, name);
} else if (fallbacks.length) {
// conditionally replace a custom property with a fallback
const clonedFallbacks = asClonedArray(fallbacks);
Object.assign(clonedFallbacks[0].raws, {
before: ''
});
child.replaceWith(...clonedFallbacks);
const nextCustomProperties = Object.assign({}, customProperties);
delete nextCustomProperties[name];
transformValueAST(root, nextCustomProperties);
child.replaceWith(...asClonedArrayWithBeforeSpacing(fallbacks, child.raws.before));
transformValueAST(root, customProperties);
}

@@ -178,9 +170,27 @@ } else {

return root;
} // retransform the current ast without a custom property (to prevent recursion)
function retransformValueAST(root, customProperties, withoutProperty) {
const nextCustomProperties = Object.assign({}, customProperties);
delete nextCustomProperties[withoutProperty];
return transformValueAST(root, nextCustomProperties);
} // match var() functions
const varRegExp = /^var$/i; // whether the node is a var() function
const isVarFunction = node => node.type === 'func' && varRegExp.test(node.value) && Object(node.nodes).length > 0; // return an array with its nodes cloned
const isVarFunction = node => node.type === 'func' && varRegExp.test(node.value) && Object(node.nodes).length > 0; // return an array with its nodes cloned, preserving the raw
const asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {
const clonedArray = asClonedArray(array, null);
if (clonedArray[0]) {
clonedArray[0].raws.before = beforeSpacing;
}
return clonedArray;
}; // return an array with its nodes cloned
const asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent)); // return a cloned node

@@ -187,0 +197,0 @@

{
"name": "postcss-custom-properties",
"version": "8.0.1",
"version": "8.0.2",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc