-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix negative utility generation and detection when using a prefix (#7295
) * Add failing tests for negative utility detection We're not generating them properly in all cases, when using at-apply we sometimes crash, and safelisting doesn't currently work as expected. * Refactor * Generate utilities for negatives before and after the prefix * Properly detect negative utilities with prefixes in the safelist * Refactor test a bit * Add class list tests * Update changelog
- Loading branch information
1 parent
ab9fd95
commit 01fbe19
Showing
6 changed files
with
384 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import parser from 'postcss-selector-parser' | ||
import { tap } from './tap' | ||
|
||
export default function (prefix, selector) { | ||
export default function (prefix, selector, prependNegative = false) { | ||
return parser((selectors) => { | ||
selectors.walkClasses((classSelector) => { | ||
tap(classSelector.value, (baseClass) => { | ||
classSelector.value = `${prefix}${baseClass}` | ||
}) | ||
let baseClass = classSelector.value | ||
let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith('-') | ||
|
||
classSelector.value = shouldPlaceNegativeBeforePrefix | ||
? `-${prefix}${baseClass.slice(1)}` | ||
: `${prefix}${baseClass}` | ||
}) | ||
}).processSync(selector) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.