Skip to content

feat(options): pass the collapseNesting enum through the Less wrapper - #4533

Merged
matthew-dean merged 2 commits into
less:alphafrom
matthew-dean:feat/collapse-nesting-option-passthrough
Sep 13, 2026
Merged

matthew-dean merged 2 commits into
less:alphafrom
matthew-dean:feat/collapse-nesting-option-passthrough

Conversation

@matthew-dean

Copy link
Copy Markdown
Member

Exposes Less v5's collapseNesting enum through the public Less render options.

Why

collapseNesting became an enum in Jess 2.0.0-alpha.20:

  • false (default) — keep authored nesting (native CSS nested output).
  • 'native' — the CSS Nesting desugaring: parent wrapped in :is(), child selector lists distributed, so each branch keeps its own specificity (matching the browser and Less 4.x).
  • 'compact' — like 'native' but also folds same-combinator descendant runs into a single :is().
  • true — deprecated alias for 'native'.

The wrapper still coerced the option to a boolean (opts.collapseNesting === true), so a 'native' or 'compact' request silently fell through to nested output. This passes the validated enum straight to the compiler; true continues to map to the flattened projection, and an unknown value is rejected with a clear error.

Tests

lessc-alpha now asserts:

  • false / 'native' / 'compact' / true each pass through to output: [{ collapseNesting: <value> }].
  • an unknown value throws.
  • 'native' distributes a child selector list (:is(.a, .b) .c, :is(.a, .b) .d) while 'compact' folds it (:is(.a, .b) :is(.c, .d)).

Full packages/less alpha suite passes (91 fixtures, packed-consumer proof against Jess 2.0.0-alpha.20).

Less v5's `collapseNesting` is now an enum — `false` (default: keep authored
nesting), `'native'` (CSS Nesting desugaring: parent `:is()`, child list
distributed, specificity-faithful), `'compact'` (also folds same-combinator
descendant runs into one `:is()`), with `true` a deprecated alias for `'native'`.

The wrapper previously coerced the option to a boolean (`=== true`), so a
`'native'`/`'compact'` request silently fell through to nested output. Pass the
validated enum through to the compiler instead; `true` still maps to the
flattened projection. lessc-alpha covers passthrough, rejection of unknown
values, and the native-distributes / compact-folds render behavior.
@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e48ebdbc-d8ca-4712-9569-3e7dfe71b2bd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The PR should not merge until explicitly undefined collapseNesting values retain the normal omitted-option behavior instead of aborting rendering.

Summary

  • Preserves true as the deprecated native-mode alias.
  • Rejects unknown explicit mode values.
  • Adds coverage for selector-list distribution and compact folding.
  • Introduces a regression for explicitly undefined optional values.

Reviews (1) · Last reviewed commit: "feat(options): pass collapseNesting enum..."

Comment thread packages/less/lib/options.js Resolved
Forwarded/spread option objects can carry `collapseNesting: undefined`; the
own-property check let that reach resolveCollapseNesting and throw. Gate on
`!== undefined` so an absent/undefined value falls back to the default nesting
mode instead of erroring. Covered in lessc-alpha.
@matthew-dean
matthew-dean merged commit 4fbdd8e into less:alpha Sep 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant