Skip to content

Commit

Permalink
Switching to postcss-value-perser (postcss/postcss-color-rebeccapurpl…
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio-Laguna authored and romainmenke committed Dec 15, 2021
1 parent c796111 commit d0483d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/postcss-color-rebeccapurple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"node": ">=12"
},
"dependencies": {
"postcss-values-parser": "^6"
"postcss-value-parser": "^4.2.0"
},
"peerDependencies": {
"postcss": "^8.3"
Expand Down
10 changes: 7 additions & 3 deletions plugins/postcss-color-rebeccapurple/src/onCSSDeclaration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse } from 'postcss-values-parser'
import valuesParser from 'postcss-value-parser'
import onCSSIdentifier from './onCSSIdentifier'
import options from './options'

Expand All @@ -7,9 +7,13 @@ const onCSSDeclaration = decl => {
const { value: originalValue } = decl

if (hasAnyRebeccapurple(originalValue)) {
const valueAST = parse(originalValue)
const valueAST = valuesParser(originalValue)

valueAST.walkType('word', onCSSIdentifier)
valueAST.walk(node => {
if (node.type === 'word') {
onCSSIdentifier(node);
}
});

const modifiedValue = String(valueAST)

Expand Down

0 comments on commit d0483d4

Please sign in to comment.