Skip to content

Commit f57bf9e

Browse files
authored
Apply custom stringification to values within functions (#68)
1 parent effab1b commit f57bf9e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/stringify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function stringifyNode(node, custom) {
1616
} else if (type === "div") {
1717
return (node.before || "") + value + (node.after || "");
1818
} else if (Array.isArray(node.nodes)) {
19-
buf = stringify(node.nodes);
19+
buf = stringify(node.nodes, custom);
2020
if (type !== "function") {
2121
return buf;
2222
}

test/stringify.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ var tests = [
8989
];
9090

9191
test("Stringify", function(t) {
92-
t.plan(tests.length + 3);
92+
t.plan(tests.length + 4);
9393

9494
tests.forEach(function(opts) {
9595
t.equal(stringify(parse(opts.fixture)), opts.fixture, opts.message);
@@ -131,4 +131,13 @@ test("Stringify", function(t) {
131131

132132
tokens[1].type = "word";
133133
t.equal(stringify(tokens), " rgba ", "Shouldn't process nodes of work type");
134+
135+
t.equal(
136+
stringify(parse("calc(1px + var(--bar))"), function(node) {
137+
if (node.type === "function" && node.value === "var") {
138+
return "10px";
139+
}
140+
}),
141+
"calc(1px + 10px)"
142+
);
134143
});

0 commit comments

Comments
 (0)