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(css parser): handle nested atRule #15665

Conversation

noreiller
Copy link
Contributor

Issue:
When using the CSS experiments and using @media or @supports in CSS code, the nested class names are not replaced with their unique identifier.

Changes:
This PR will handle @media and @supports atRule identifiers and enable the replacements of the nested rules names with the unique ids.

CSS input code:

.main {
	font-size: var(--large);
	color: darkblue;
}
@media (min-width: 1024px) {
	.main {
		color: green;
	}
}
@supports (display: grid) {
	.main {
		display: grid
	}
}

The compiled CSS code with the issue:
You can see that only the top-level class name is replaced.

.app-491-D {
	font-size: var(--large);
	color: darkblue;
}
@media (min-width: 1024px) {
	.main {
		color: green;
	}
}
@supports (display: grid) {
	.main {
		display: grid
	}
}

The compiled CSS code thanks to the fix:
You can see that all the class names are replaced.

.app-491-D {
	font-size: var(--large);
	color: darkblue;
}
@media (min-width: 1024px) {
	.app-491-D {
		color: green;
	}
}
@supports (display: grid) {
	.app-491-D {
		display: grid
	}
}

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 14, 2022

CLA Not Signed

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@noreiller noreiller force-pushed the fix-experiments-css-at-rule-nested branch from c6d59c7 to 811d278 Compare April 14, 2022 16:28
@vankop
Copy link
Member

vankop commented Apr 15, 2022

please accept cla

@noreiller
Copy link
Contributor Author

please accept cla

@vankop I contacted my company to accept CLA as a Corporate Contributor. I hope this will be done next week.

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs a test case. The example is not enough to test the behavior

@webpack-bot
Copy link
Contributor

@noreiller Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@noreiller
Copy link
Contributor Author

This also needs a test case. The example is not enough to test the behavior

Hello @sokra , thanks for your review, I added some config cases tests.

This will handle @media and @supports atRule identifiers and
enable the replacements of the nested rules names with the
unique ids.
@noreiller noreiller force-pushed the fix-experiments-css-at-rule-nested branch from cf24c1d to 7b71e81 Compare May 11, 2022 08:01
@noreiller
Copy link
Contributor Author

Due to technical issues between the Linux foundation and my company to sign the CLA, I close this PR and created a new one on my personal github.

@noreiller noreiller closed this May 11, 2022
@noreiller noreiller deleted the fix-experiments-css-at-rule-nested branch May 11, 2022 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants