Problem/Motivation

At Rules are stripped from output stylesheet.
StylesheetGenerator::generateCss strips all surrounding rules by calling CSSBlockList::getAllDeclarationBlocks() (including "AtRuleBlockList").

So this rule will work :

.d-md-none {
  @media (min-width: 768px) {
    display: none !important;
  }
}

But not this one :

@media (min-width: 768px) {
  .d-md-none {
    display: none !important;
  }
}

Steps to reproduce

  • install ui_suite_bootstrap
  • install ui_styles
  • Add this div anywhere <div class="d-block d-md-none">TEST</div>
  • The div should hide in desktop but does not

Proposed resolution

Do not get blocks with getAllDeclarationBlocks() method. Process level 1 content of parsed css separately depending on their type. For AtRuleBlockList items, process included blocks and generate css by calling render on the AtRule not on each child.

Issue fork ui_styles-3547507

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mattlc created an issue. See original summary.

mattlc’s picture

Status: Active » Needs review
mattlc’s picture

Assigned: mattlc » Unassigned

Tests added.

grimreaper’s picture

Assigned: Unassigned » grimreaper

  • grimreaper committed 2d807acc on 8.x-1.x authored by mattlc
    [#3547507] feat: At Rules are stripped from output stylesheet
    
    By:...
grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.