MCPcopy Create free account
hub / github.com/callstack/linaria / constructor

Method constructor

packages/postcss-linaria/src/stringify.ts:62–84  ·  view source on GitHub ↗

@inheritdoc

(builder: Builder)

Source from the content-addressed store, hash-verified

60class LinariaStringifier extends Stringifier {
61 /** @inheritdoc */
62 public constructor(builder: Builder) {
63 const wrappedBuilder: Builder = (
64 str: string,
65 node?: AnyNode,
66 type?: 'start' | 'end'
67 ): void => {
68 // We purposely ignore the root node since the only thing we should
69 // be stringifying here is already JS (before/after raws) so likely
70 // already contains backticks on purpose.
71 //
72 // Similarly, if there is no node, we're probably stringifying
73 // pure JS which never contained any CSS. Or something really weird
74 // we don't want to touch anyway.
75 //
76 // For everything else, we want to escape backticks.
77 if (!node || node?.type === 'root') {
78 builder(str, node, type);
79 } else {
80 builder(str.replace(/\\/g, '\\\\').replace(/`/g, '\\`'), node, type);
81 }
82 };
83 super(wrappedBuilder);
84 }
85
86 public override atrule(node: AtRule, semicolon?: boolean) {
87 const { params } = node;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected