From 337997283d1f49a6ffb150eb1322bdf48957ba5b Mon Sep 17 00:00:00 2001 From: Winston <> Date: Wed, 16 Sep 2020 14:19:23 +0800 Subject: [PATCH] :alien: Replace root.walkDecls with Declaration to work with PostCSS 8 correctly --- src/index.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index 9963a31..eff1994 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,3 @@ -const postcss = require('postcss') const R = require('ramda') const { @@ -31,17 +30,15 @@ module.exports = ({ return { postcssPlugin: 'postcss-sparrow', - Root (root, result) { + Declaration (decl) { R.map( - (transformation) => root.walkDecls((decl) => { - const result = R.when( - R.pipe( - R.prop('parent'), - getNodesBySelectors(transformation) - ), - R.juxt(transformation.callbacks) - )(decl) - }) + (transformation) => R.when( + R.pipe( + R.prop('parent'), + getNodesBySelectors(transformation) + ), + R.juxt(transformation.callbacks) + )(decl) )(validatedTransformations) } }