Skip to content

Commit 459d1ac

Browse files
committed
fix(reduced-motion): enhance mixin to support root and html context for animation classes
1 parent 638da7d commit 459d1ac

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎src/scss/02-tools/_m-reduced-motion.scss‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010
*
1111
* @include reduced-motion { ... }
1212
* → html.no-js-animation & { ... }
13+
* → html.no-js-animation { ... } when used at root / inside :root or html
1314
*
1415
* @include allows-motion { ... }
1516
* → html.js-animation & { ... }
17+
* → html.js-animation { ... } when used at root / inside :root or html
1618
*
1719
*/
1820

1921
@mixin _html-animation-class($class) {
20-
@if not & {
21-
html.#{$class} {
22+
// `:root` and `html` are the same element as the animation class host, so they
23+
// cannot appear as descendants of `html.#{$class}`.
24+
$parent: "#{&}";
25+
26+
@if not & or $parent == ":root" or $parent == "html" {
27+
@at-root html.#{$class} {
2228
@content;
2329
}
2430
} @else {

0 commit comments

Comments
 (0)