@@ -13598,6 +13598,39 @@ const _valueComponents = (path, node, writer) => {
1359813598 return components;
1359913599};
1360013600
13601+ /**
13602+ * A custom property's value as written, kept comments included, and with the
13603+ * text a visitor's edit left in place of each token holding one.
13604+ * @param {Node} node the declaration whose tokens are printed
13605+ * @param {PrintContext} writer the print context (holds the kept comments)
13606+ * @param {number} from source offset the tokens start at
13607+ * @param {number} to source offset they end at
13608+ * @returns {string} the printed value
13609+ */
13610+ const _customPropertySource = (node, writer, from, to) => {
13611+ // Straight from source, so the kept comments in it are already there —
13612+ // claim them, or the writer emits them a second time ahead of the next
13613+ // top-level node.
13614+ writer.takeInserts(from, to);
13615+ const input = _S._input;
13616+ if (_edits.length === 0 || !_holdsEdit(node)) {
13617+ const value = input.slice(from, to);
13618+ return to === input.length ? _closeAtEof(value) : value;
13619+ }
13620+ let out = "";
13621+ let at = from;
13622+ const i0 = _nodeIndex(node);
13623+ const first = _listStarts[i0];
13624+ const last = first + _listLens[i0];
13625+ for (let k = first; k < last; k++) {
13626+ const child = _nodeRef(_flat[k]);
13627+ if (!_holdsEdit(child)) continue;
13628+ out += input.slice(at, _startOf(child)) + writer.get(child);
13629+ at = _endOf(child);
13630+ }
13631+ return out + input.slice(at, to);
13632+ };
13633+
1360113634/**
1360213635 * A custom property's value, token for token: every token is written back as
1360313636 * written, and a run of whitespace and dropped comments between two of them is
@@ -13608,9 +13641,13 @@ const _valueComponents = (path, node, writer) => {
1360813641 * @param {PrintContext} writer the print context (holds the kept comments)
1360913642 * @param {number} from source offset the tokens start at
1361013643 * @param {number} to source offset they end at
13644+ * @param {boolean=} asWritten keep the boundaries as written too, as beautify does
1361113645 * @returns {string} the printed value
1361213646 */
13613- const _customPropertyValue = (path, node, writer, from, to) => {
13647+ const _customPropertyValue = (path, node, writer, from, to, asWritten) => {
13648+ if (asWritten) return _customPropertySource(node, writer, from, to);
13649+ // Read once per value: a token holding a visitor's edit prints as it left it.
13650+ const edited = _edits.length !== 0 && _holdsEdit(node);
1361413651 let out = "";
1361513652 let at = from;
1361613653 // The boundary held back: whether a whitespace token stood in it, whether a
@@ -13658,7 +13695,10 @@ const _customPropertyValue = (path, node, writer, from, to) => {
1365813695 operator = false;
1365913696 continue;
1366013697 }
13661- const text = _customPropertyToken(path, child, writer);
13698+ const text =
13699+ edited && _holdsEdit(child)
13700+ ? writer.get(child)
13701+ : _customPropertyToken(path, child, writer);
1366213702 // WHY: CSS Values 4 §10.1 requires whitespace on both sides of a `+` or `-`
1366313703 // in a math function, and this value is a token stream whose consuming
1366413704 // context is unknown here — `--tail:(1px) - (2px)` reaches a `calc()` by
0 commit comments