Skip to content

Commit 142b4a0

Browse files
committed
add optional condition to hasAtRule
1 parent bec7ee0 commit 142b4a0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/lib/substituteClassApplyAtRules.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import substituteScreenAtRules from './substituteScreenAtRules'
1111
import prefixSelector from '../util/prefixSelector'
1212
import { useMemo } from '../util/useMemo'
1313

14-
function hasAtRule(css, atRule) {
15-
let foundAtRule = false
14+
function hasAtRule(css, atRule, condition = () => true) {
15+
let found = false
1616

17-
css.walkAtRules(atRule, () => {
18-
foundAtRule = true
19-
return false
17+
css.walkAtRules(atRule, (node) => {
18+
if (condition(node)) {
19+
found = true
20+
return false
21+
}
2022
})
2123

22-
return foundAtRule
24+
return found
2325
}
2426

2527
function cloneWithoutChildren(node) {

0 commit comments

Comments
 (0)