Skip to content

Commit 96b646e

Browse files
fritz-cEll Bradshaw
authored and
Ell Bradshaw
committed
pass indentation config to css.stringify
Helps the library comply with Jest's serializer's indent configuration, which in turn fixes styled-components#355
1 parent 97e8f8a commit 96b646e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/styleSheetSerializer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ const getAtRules = (ast, filter) =>
7070
return acc.concat(atRule);
7171
}, []);
7272

73-
const getStyle = (classNames) => {
73+
const getStyle = (classNames, config = {}) => {
7474
const ast = getCSS();
7575
const filter = filterRules(classNames);
7676
const rules = ast.stylesheet.rules.filter(filter);
7777
const atRules = getAtRules(ast, filter);
7878

7979
ast.stylesheet.rules = rules.concat(atRules);
8080

81-
return css.stringify(ast);
81+
return css.stringify(ast, { indent: config.indent });
8282
};
8383

8484
const getClassNamesFromSelectorsByHashes = (classNames, hashes) => {
@@ -149,7 +149,7 @@ module.exports = {
149149
classNames = filterClassNames(classNames, hashes);
150150
unreferencedClassNames = filterUnreferencedClassNames(unreferencedClassNames, hashes);
151151

152-
const style = getStyle(classNames);
152+
const style = getStyle(classNames, config);
153153
const classNamesToReplace = getClassNamesFromSelectorsByHashes(classNames, hashes);
154154
const code = printer(val, config, indentation, depth, refs);
155155

0 commit comments

Comments
 (0)