Skip to content

postcss-custom-media: incorrect rendering with nested rules #1519

@massimo-cassandro

Description

@massimo-cassandro

Bug description

In custom media queries inside nested rules, the parent selectors are ignored

Source CSS

.some-class {

  .nested {
    flex-direction: column;

    @media (--my-custom-media) {
      flex-direction: row;
    }
  }
}

Expected CSS

.some-class {
  .nested {
    flex-direction: column;
  }
}
@media (min-width: 480px) { /* --my-custom-media */
  .some-class {
    .nested {
      flex-direction: row;
    }
  }
}

Actual CSS

.some-class {
  .nested {
    flex-direction: column;
  }
}
@media (min-width: 480px) { /* --my-custom-media */
  .nested {
    flex-direction: row;
  }
}

Playgound example

No response

Does it happen with npx @csstools/csstools-cli <plugin-name> minimal-example.css?

N/A

Debug output

No response

Extra config

No response

What plugin are you experiencing this issue on?

PostCSS Custom Media Queries

Plugin version

11.0.5

What OS are you experiencing this on?

macOS

Node Version

22.3.0

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this bug?

  • I'm willing to open a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions