postcss-color-functional-notation
Advanced tools
Comparing version 2.0.0 to 2.0.1
# Changes to PostCSS Color Functional Notation | ||
### 2.0.1 (September 18, 2018) | ||
- Updated: PostCSS Values Parser 2 (patch for this project) | ||
### 2.0.0 (September 17, 2018) | ||
@@ -4,0 +8,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var postcss = _interopDefault(require('postcss')); | ||
var parser = _interopDefault(require('postcss-values-parser')); | ||
var valuesParser = _interopDefault(require('postcss-values-parser')); | ||
@@ -13,7 +13,7 @@ var index = postcss.plugin('postcss-color-functional-notation', opts => { | ||
root.walkDecls(decl => { | ||
const value = decl.value; | ||
const originalValue = decl.value; | ||
if (colorAnyRegExp.test(value)) { | ||
const ast = parser(value).parse(); | ||
ast.walkType('func', node => { | ||
if (colorAnyRegExp.test(originalValue)) { | ||
const valueAST = valuesParser(originalValue).parse(); | ||
valueAST.walkType('func', node => { | ||
if (colorRegExp.test(node.value)) { | ||
@@ -42,3 +42,3 @@ const children = node.nodes.slice(1, -1); | ||
if (isSlash(slashNode)) { | ||
if (slashNode && isSlash(slashNode)) { | ||
slashNode.replaceWith(newComma()); | ||
@@ -59,10 +59,12 @@ } | ||
}); | ||
const newValue = String(ast); | ||
const modifiedValue = String(valueAST); | ||
if (preserve) { | ||
decl.cloneBefore({ | ||
value: newValue | ||
}); | ||
} else { | ||
decl.value = newValue; | ||
if (modifiedValue !== originalValue) { | ||
if (preserve) { | ||
decl.cloneBefore({ | ||
value: modifiedValue | ||
}); | ||
} else { | ||
decl.value = modifiedValue; | ||
} | ||
} | ||
@@ -83,21 +85,21 @@ } | ||
const isAlphaValue = node => isCalc(node) || Object(node).type === 'number' && alphaUnitMatch.test(node.unit); | ||
const isAlphaValue = node => isCalc(node) || node.type === 'number' && alphaUnitMatch.test(node.unit); | ||
const isCalc = node => Object(node).type === 'func' && calcFuncMatch.test(node.value); | ||
const isCalc = node => node.type === 'func' && calcFuncMatch.test(node.value); | ||
const isHue = node => isCalc(node) || Object(node).type === 'number' && hueUnitMatch.test(node.unit); | ||
const isHue = node => isCalc(node) || node.type === 'number' && hueUnitMatch.test(node.unit); | ||
const isNumber = node => isCalc(node) || Object(node).type === 'number' && node.unit === ''; | ||
const isNumber = node => isCalc(node) || node.type === 'number' && node.unit === ''; | ||
const isPercentage = node => isCalc(node) || Object(node).type === 'number' && (node.unit === '%' || node.unit === '' && node.value === '0'); | ||
const isPercentage = node => isCalc(node) || node.type === 'number' && (node.unit === '%' || node.unit === '' && node.value === '0'); | ||
const isHslish = node => Object(node).type === 'func' && hslishRegExp.test(node.value); | ||
const isHslish = node => node.type === 'func' && hslishRegExp.test(node.value); | ||
const isHslRgb = node => Object(node).type === 'func' && hslRgbFuncMatch.test(node.value); | ||
const isHslRgb = node => node.type === 'func' && hslRgbFuncMatch.test(node.value); | ||
const isHslaRgba = node => Object(node).type === 'func' && hslaRgbaFuncMatch.test(node.value); | ||
const isHslaRgba = node => node.type === 'func' && hslaRgbaFuncMatch.test(node.value); | ||
const isRgbish = node => Object(node).type === 'func' && rgbishRegExp.test(node.value); | ||
const isRgbish = node => node.type === 'func' && rgbishRegExp.test(node.value); | ||
const isSlash = node => Object(node).type === 'operator' && node.value === '/'; | ||
const isSlash = node => node.type === 'operator' && node.value === '/'; | ||
@@ -114,3 +116,3 @@ const functionalHSLMatch = [isHue, isPercentage, isPercentage, isSlash, isAlphaValue]; | ||
const newComma = () => parser.comma({ | ||
const newComma = () => valuesParser.comma({ | ||
value: ',' | ||
@@ -117,0 +119,0 @@ }); |
{ | ||
"name": "postcss-color-functional-notation", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Use space and slash separated color notation in CSS", | ||
@@ -31,7 +31,7 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>", | ||
"postcss": "^7.0.2", | ||
"postcss-values-parser": "^1.5.0" | ||
"postcss-values-parser": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/core": "^7.1.0", | ||
"@babel/preset-env": "^7.1.0", | ||
"babel-eslint": "^9.0.0", | ||
@@ -43,3 +43,3 @@ "eslint": "^5.6.0", | ||
"rollup": "^0.66.0", | ||
"rollup-plugin-babel": "^4.0.1" | ||
"rollup-plugin-babel": "^4.0.3" | ||
}, | ||
@@ -46,0 +46,0 @@ "eslintConfig": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42678
176
0
+ Addedpostcss-values-parser@2.0.1(transitive)
- Removedpostcss-values-parser@1.5.0(transitive)
Updatedpostcss-values-parser@^2.0.0