Skip to content

Commit

Permalink
fix(material/theming): Fix subtle bug in current-selector-or-root
Browse files Browse the repository at this point in the history
There was a sublte bug in the previous implementation. Consider the case:

```scss
div {
  @include current-selector-or-root() {
    color: red;
  }
  color: green;
}
```

The previous implementation lifted the `color: red;` into a separate
selector block that came *after* the initial one, resulting in the order
being flipped:

```css
div {
  color: green;
}
div {
  color: red;
}
```

The new code will produce the correct ordering:

```css
div {
  color: red;
  color: green;
}
```
  • Loading branch information
mmalerba committed Oct 4, 2023
1 parent 2f958ac commit 4f70a38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/material/core/style/_sass-utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
/// @content Content to output under the current selector, or root selector if there is no current
/// selector.
@mixin current-selector-or-root($root: html) {
@at-root #{& or $root} {
@if & {
@content;
}
@else {
#{$root} {
@content;
}
}
}

/// A version of the standard `map.merge` function that takes a variable number of arguments.
Expand Down

0 comments on commit 4f70a38

Please sign in to comment.