Skip to content

inconsistent handling of commented CSS rules #1445

@8ctopus

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) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions