Refactor (slice 5): extract CSS/style resolution into Style/StyleResolutionTrait#252
Merged
Merged
Conversation
…t (slice 5) Pure, behavior-preserving move of the CSS / style-resolution concern out of HtmlTransformer into a dedicated Style/StyleResolutionTrait. Methods extracted verbatim (no logic or signature changes): presentationAttributes, mergedPresentationStyle, isHighValueStyledElement, staticStyleRules, safeVisualDeclarations, cssDeclarations, cssDeclarationString, isSupportedCssSelector, matchesCssSelector, normalizeCssSelector, matchesCssSelectorPart, presentationClassName, isBehaviorHookClassName, layoutAttribute, hasGridLikeClass. HtmlTransformer `use`s the new trait; $staticStyleRules property and the class-promotion / provenance helpers stay on HtmlTransformer. Refs #242 (slice 5: CSS/style resolution). Parity 128->128, canonical + full composer test green, zero block-output diff. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Refs #242 — decomposition epic, slice 5: CSS / style resolution.
What moved
Pure, behavior-preserving extraction of the CSS / style-resolution concern out of
HtmlTransformer.phpinto a dedicatedsrc/HtmlToBlocks/Style/StyleResolutionTrait.php.HtmlTransformernowuses the trait (alongsideDomHelpersTrait); methods were moved verbatim — no logic, signature, or output changes.Moved (15 methods):
presentationAttributes,mergedPresentationStyle,isHighValueStyledElement,staticStyleRules,safeVisualDeclarations,cssDeclarations,cssDeclarationString,isSupportedCssSelector,matchesCssSelector,normalizeCssSelector,matchesCssSelectorPart,presentationClassName,isBehaviorHookClassName,layoutAttribute,hasGridLikeClass.This is the CSS-rule resolution the font/typography path and
ButtonStyleResolverrely on, given a single home so style work stops colliding in the god-object.What stayed
The
$staticStyleRules/$staticClassPromotionsproperties, the class-promotion runtime-island helpers (detectStaticClassPromotions,promotedClassName), and the provenance recorders remain onHtmlTransformer. The trait calls back into$this->attr()/$this->safeAnchor()(DomHelpersTrait),$this->promotedClassName(),$this->cardLikeChildCount(), and the$staticStyleRulesproperty — all composed ontoHtmlTransformer.Behavior-preserving proof
composer test(canonical + parity + packaging) green. Zero block-output diff. No fixture touched.Line-count delta
HtmlTransformer.php: 5351 → 5040 (-311 lines). NewStyle/StyleResolutionTrait.php: 335 lines.Scope limited to
HtmlTransformer.php+ the newStyle/trait. Do not merge without review.