-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringify.js
More file actions
28 lines (27 loc) · 957 Bytes
/
Copy pathstringify.js
File metadata and controls
28 lines (27 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Document } from "./nodes/document.js";
/**
* Serializes a PostCSS node into its string representation.
*
* @param {import('postcss').AnyNode} node - The PostCSS node to be stringified.
* @param {import('postcss').Builder} builder - The builder function responsible for handling the serialized output.
* @returns {void} This function does not return a value; it utilizes the builder function for output.
*/
export default function stringify(node, builder) {
if (!(node instanceof Document)) {
builder(node.toString(), node);
return;
}
if (node.nodes && node.nodes.length) {
node.nodes.forEach((root) => {
builder(root.raws.codeBefore, root);
builder(root.raws.stringType, root);
builder(root.toString(), root);
builder(root.raws.stringType, root);
if (root.raws.codeAfter) {
builder(root.raws.codeAfter, root);
}
});
} else {
builder(node.source.input.css, node);
}
}