Skip to content

Inconsistent handling of commented CSS rules #1445

Description

@8ctopus
$input = <<<CSS
a {
    /* margin: 10px 10px 10px 0; */
    outline: none;
}

CSS;

$document = (new \Sabberworm\CSS\Parser($input))
    ->parse();

$format = OutputFormat::createPretty();

echo $document->render($format);

becomes:

a {
        /* margin: 10px 10px 10px 0; */
        outline: none;
}

while if you update the input to remove the outline property,

a {
    /* margin: 10px 10px 10px 0; */
}

it becomes:

a {}

so any commented rule(s) not followed by a CSS rule are removed from the resulting rule set.

Problem occurs here because getRules() returns an empty array

foreach ($this->getRules() as $rule) {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions