Visitar URL original
Omit "known removable" plain CSS at-rules · Issue #3900 · sass/sass · GitHub
Skip to content

Omit "known removable" plain CSS at-rules #3900

Open

Description

@fallenturtle

If you have a placeholder with a container query in it, when compiled the CSS will output an empty container query.
For example:

%wombat {
    @media (width <= 100px) {
      margin-bottom: 100px;
    }
    @container (width <= 100px) {
      margin-bottom: 100px;
    }
}

will output this:
@container (width <= 100px) {}

Here it is in a playground:
https://sass-lang.com/playground/#eJwzNORSLc/PTUosUajmUgACh9zUlMxEBY3yzJSSDAUbWwVDA4OCCk2orIJCbmJRemaeblJ+SUl+rhVE1hosVwvRn5yfV5KYmZdaRJ4ZtQCnTSiP

Activity

  1. transferred this issue fromsass/dart-sasson Jul 18, 2024
  2. nex3 commented on Jul 18, 2024

    @nex3
    Contributor

    This is more or less an expected consequence of the way Sass works. Sass doesn't know what a @container rule is; as far as it knows, @container (width <= 100px) {} has some special meaning that's different than the rule being omitted entirely. This is a design feature: it allows Sass to support new CSS rules without needing to constantly update its syntax as CSS evolves.

    Separately from that, Sass also has what we call "bubbling" behavior for nested at-rules. In order to support older browsers that don't support CSS nesting, Sass will "bubble up" any nested at rules, converting your stylesheet into:

    @media (width <= 100px) {
      %wombat {margin-bottom: 100px}
    }
    @container (width <= 100px) {
      %wombat {margin-bottom: 100px}
    }

    After it does this, it will remove the placeholder selectors and you'll be left with the empty container rule.

    All that said—I think it would be fine to have a list of "known removable" at-rule names that we know to be safe to remove if they have no children.

  3. changed the title [-]Container queries within placeholders get outputted in compiled CSS[/-] [+]Omit "known removable" plain CSS at-rules[/+] on Jul 18, 2024
  4. MrSuddenJoy commented on Sep 28, 2024

    @MrSuddenJoy
  5. nex3 commented on Oct 1, 2024

    @nex3
    Contributor

    I mean in the implementation of Sass.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions