Don’t crash when important and parent selectors are equal in @apply (#12112)

* Don’t crash when important and parent selectors are equal in `@apply`

* Update changelog
This commit is contained in:
Jordan Pittman 2023-09-29 16:04:32 -04:00 • committed by GitHub
parent d32228628e
commit 457d2b1b1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View file

@ -553,6 +553,13 @@ function processApply(root, context, localCache) {
? parent.selector.slice(importantSelector.length)
: parent.selector
// If the selector becomes empty after replacing the important selector
// This means that it's the same as the parent selector and we don't want to replace it
// Otherwise we'll crash
if (parentSelector === '') {
parentSelector = parent.selector
}
rule.selector = replaceSelector(parentSelector, rule.selector, applyCandidate)
// And then re-add it if it was removed