Skip to content

Strip empty rulesets that contain only CSS comments #4276

Open
@jandre3000

Description

@jandre3000

To reproduce:

Currently, when a ruleset contains nothing but a Less comment, that ruleset is considered empty and is stripped from the compile CSS output. The same is not true for CSS comments. Consider the following example:

Current behavior:

Screenshot 2024-08-14 at 12 41 10 PM

Expected behavior:
From a developer's perspective, I'd expect that the two rulesets would be treated equally, regardless of the comment format, and that neither would produce any CSS output.

When combined with nesting, this behaviour can lead to unnecessarily duplicated code, as was the case in the following issue:
https://phabricator.wikimedia.org/T372101

e.g.
Screenshot 2024-08-14 at 12 48 36 PM

Environment information:

  • less version: 4.2

p.s.
I think this is related to #2477 but I wasn't sure to what extent.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions