fix(php-transformer): stop WordPress body classes inheriting source frames - #1863
Merged
Merged
Conversation
…rames body_class() stamps template names such as page, home, and search onto the document body. A source stylesheet that centers a same-named element then applies its max-width and gutters twice, narrowing every line box and stretching the page. Neutralize the frame properties on body for the reserved template names only, next to the existing body-owned compatibility rules.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
body_class()stamps template names onto<body>:page,home,search,single, and friends. A source stylesheet that centers an element of the same name therefore styles the document body too.On the academic CV fixture the author rule is:
WordPress renders
<body class="home ... page page-id-5">and the source<main class="page">, so the frame is paid twice:h1widthddwidthText content is identical; the extra 765px is line rewrapping inside a column that lost one horizontal gutter pair.
Fix
Emit a bounded compatibility rule beside the existing body-owned rules in
WordPressCompatCss. When a source stylesheet gives a bare reserved template class frame geometry, reset only those properties onbody:The element keeps its own rule. Paint is untouched. Unreserved classes, element-qualified selectors (
main.page), descendant selectors, and non-frame declarations are all left alone.Validation
php php-transformer/tests/unit/wordpress-body-class-collision.php(13 assertions, registered incomposer test:unit)php php-transformer/tests/unit/admin-bar-accommodation.php,author-cascade-layer-order.php,artifact-author-stylesheet-projection.phpcomposer validate --strictAI assistance
.pageframe, implemented the compat rule, and wrote the coverage.