Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 3405bc4

Browse files
mmalerbaabhiomkar
authored andcommitted
fix(feature-targeting): prevent accidental nesting of mdc-feature-targets mixin (#4281)
1 parent 67a1f18 commit 3405bc4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/mdc-feature-targeting/_mixins.scss

+11
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@
2222

2323
@import "./functions";
2424

25+
// Tracks whether the current context is inside a `mdc-feature-targets` mixin.
26+
$mdc-feature-targets-context_: false;
27+
2528
// Mixin that annotates the contained styles as applying to specific cross-cutting features
2629
// indicated by the given list of feature targets.
2730
@mixin mdc-feature-targets($feature-targets...) {
31+
// Prevent accidental nesting of this mixin, which could lead to unexpected results.
32+
@if $mdc-feature-targets-context_ {
33+
@error "mdc-feature-targets must not be used inside of another mdc-feature-targets block";
34+
}
35+
36+
$mdc-feature-targets-context_: true !global;
2837
$parsed-targets: mdc-feature-parse-targets($feature-targets);
2938

3039
@if mdc-feature-is-query-satisfied_(map-get($parsed-targets, query), map-get($parsed-targets, available)) {
3140
@content;
3241
}
42+
43+
$mdc-feature-targets-context_: false !global;
3344
}

0 commit comments

Comments
 (0)