Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @apply selector rewriting when multiple classes are involved #9107

merged 3 commits into from Aug 15, 2022


Copy link

@thecrypticace thecrypticace commented Aug 15, 2022

This PR fixes two problems when using @apply:

  1. Incorrect placement of element selectors when multiple classes are joined in a selector

Given: { color: red; }
section { @apply bar; }

We would naively replace the .bar portion with section producing .foosection which is obviously wrong. This did not happen when applying foo because this simple replacement produced something that happened to be correct

  1. Only replacing the first occurrence of a candidate in a selector: (reverted due to this not being 100% correct either)


.foo + .foo { color: red; }
section { @apply foo; }

We would produce:

section + .foo { color: red; }

This is not correct because the foo class may not even exist at all if .foo + .foo is defined in the components or utilities layers.

Fixes #9093

@thecrypticace thecrypticace force-pushed the feature/apply-selector-rewriting branch from 35325a4 to 1754e9a Compare August 15, 2022 17:52
@thecrypticace thecrypticace force-pushed the feature/apply-selector-rewriting branch from 1754e9a to afd069c Compare August 15, 2022 18:09
@thecrypticace thecrypticace marked this pull request as ready for review August 15, 2022 18:16
@thecrypticace thecrypticace merged commit ef74fd3 into master Aug 15, 2022
@thecrypticace thecrypticace deleted the feature/apply-selector-rewriting branch August 15, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Sibling selectors of components don't work on classes applying them
1 participant