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

Style engine: prettify combined selectors #43003

Merged
merged 2 commits into from
Aug 5, 2022

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Aug 5, 2022

What?

A follow up to

This PR:

  • Inserts a new line after combined selectors
  • Returns empty string where no declarations are found in a CSS rule
  • Adds tests for both

Why?

The difference in prettified output is:

Trunk

.wp-block-column.wp-container-9 > :where(:not(.alignleft):not(.alignright):not(.alignfull)),.wp-block-column.wp-container-13 > :where(:not(.alignleft):not(.alignright):not(.alignfull)),.wp-block-column.wp-container-17 > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
	max-width: 26px;
	margin-left: auto !important;
	margin-right: auto !important;
}

This PR

.wp-block-column.wp-container-9 > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
.wp-block-column.wp-container-13 > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
.wp-block-column.wp-container-17 > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
	max-width: 26px;
	margin-left: auto !important;
	margin-right: auto !important;
}

How?

Adding a \n after each , in the selector string.

Testing Instructions

Run the tests:
npm run tests-unit-php

Check the source of a page that has a bunch of similar layout blocks (e.g., group blocks).

The selectors should be stacked in development, not printed in a line.

Adding tests
Returning empty string where no declarations are found in a CSS rule
@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Package] Style Engine /packages/style-engine labels Aug 5, 2022
@ramonjd ramonjd self-assigned this Aug 5, 2022
Copy link
Contributor

@glendaviesnz glendaviesnz left a comment

Choose a reason for hiding this comment

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

Worked as advertised to me:

With SCRIPT_DEBUG set:

Screen Shot 2022-08-05 at 3 06 40 PM

Without SCRIPT_DEBUG set:

Screen Shot 2022-08-05 at 3 05 19 PM

@ramonjd ramonjd merged commit e89b95c into trunk Aug 5, 2022
@ramonjd ramonjd deleted the update/style-engine-prettify-combined-selectors branch August 5, 2022 04:19
@github-actions github-actions bot added this to the Gutenberg 13.9 milestone Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Style Engine /packages/style-engine [Type] Enhancement A suggestion for improvement.
Projects
Status: 🏆 Done
Development

Successfully merging this pull request may close these issues.

2 participants