From b36ed3e2afae6f6d016fadb46ac494a016acb4cf Mon Sep 17 00:00:00 2001 From: Bart Veneman Date: Fri, 26 Jul 2024 23:16:51 +0200 Subject: [PATCH] convert parentheses to consts --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 719f563..68ef2ea 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,8 @@ const SPACE = ' ' const EMPTY_STRING = '' const COLON = ':' const SEMICOLON = ';' +const OPEN_PARENTHESES = '(' +const CLOSE_PARENTHESES = ')' const TYPE_ATRULE = 'Atrule' const TYPE_RULE = 'Rule' const TYPE_BLOCK = 'Block' @@ -160,7 +162,7 @@ export function format(css, { minify = false } = {}) { buffer += pseudo if (child.children) { - buffer += '(' + print_simple_selector(child) + ')' + buffer += OPEN_PARENTHESES + print_simple_selector(child) + CLOSE_PARENTHESES } break } @@ -378,7 +380,7 @@ export function format(css, { minify = false } = {}) { } else if (node.type === TYPE_OPERATOR) { buffer += print_operator(node) } else if (node.type === 'Parentheses') { - buffer += '(' + print_list(node.children) + ')' + buffer += OPEN_PARENTHESES + print_list(node.children) + CLOSE_PARENTHESES } else { buffer += substr(node) } @@ -455,7 +457,7 @@ export function format(css, { minify = false } = {}) { * @param {import('css-tree').FunctionNode} node */ function print_function(node) { - return lowercase(node.name) + '(' + print_list(node.children) + ')' + return lowercase(node.name) + OPEN_PARENTHESES + print_list(node.children) + CLOSE_PARENTHESES } /**