Skip to content

Commit 4f70a38

Browse files
committed
fix(material/theming): Fix subtle bug in current-selector-or-root
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; } ```
1 parent 2f958ac commit 4f70a38

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/material/core/style/_sass-utils.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
/// @content Content to output under the current selector, or root selector if there is no current
1111
/// selector.
1212
@mixin current-selector-or-root($root: html) {
13-
@at-root #{& or $root} {
13+
@if & {
1414
@content;
1515
}
16+
@else {
17+
#{$root} {
18+
@content;
19+
}
20+
}
1621
}
1722

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

0 commit comments

Comments
 (0)