@typographist/postcss
Version:
Toolkit for the rapid construction of interfaces with high quality typography.
33 lines (26 loc) • 754 B
JavaScript
// cleanNode :: Object -> Object
const cleanNode = (node) => {
node.raws = {
...(node.raws.between ? { between: node.raws.between } : {}),
...{ semicolon: true },
...(node.raws.important ? { important: node.raws.important } : {}),
};
return node;
};
// transformAfterNodes :: (Object) -> Object | Null
const transformAfterNodes = (node) => {
const affectedNodes = node.parent.nodes
.slice(node.parent.nodes.indexOf(node) + 1)
.map(cleanNode);
if (affectedNodes.length) {
const afterParent = cleanNode(node.parent.clone()).removeAll();
node.parent.after(afterParent);
afterParent.append(affectedNodes);
return afterParent;
}
return null;
};
module.exports = {
cleanNode,
transformAfterNodes,
};