Skip to content

Refactor (slice 5): extract CSS/style resolution into Style/StyleResolutionTrait#252

Merged
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-style-resolution
Jun 28, 2026
Merged

Refactor (slice 5): extract CSS/style resolution into Style/StyleResolutionTrait#252
chubes4 merged 1 commit into
trunkfrom
refactor/htmltransformer-style-resolution

Conversation

@chubes4

@chubes4 chubes4 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Refs #242 — decomposition epic, slice 5: CSS / style resolution.

What moved

Pure, behavior-preserving extraction of the CSS / style-resolution concern out of HtmlTransformer.php into a dedicated src/HtmlToBlocks/Style/StyleResolutionTrait.php. HtmlTransformer now uses the trait (alongside DomHelpersTrait); 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 ButtonStyleResolver rely on, given a single home so style work stops colliding in the god-object.

What stayed

The $staticStyleRules / $staticClassPromotions properties, the class-promotion runtime-island helpers (detectStaticClassPromotions, promotedClassName), and the provenance recorders remain on HtmlTransformer. The trait calls back into $this->attr() / $this->safeAnchor() (DomHelpersTrait), $this->promotedClassName(), $this->cardLikeChildCount(), and the $staticStyleRules property — all composed onto HtmlTransformer.

Behavior-preserving proof

  • Baseline (origin/trunk): canonical contracts green, parity 128 fixtures.
  • After: canonical contracts green, parity 128 → 128, full composer test (canonical + parity + packaging) green. Zero block-output diff. No fixture touched.

Line-count delta

HtmlTransformer.php: 5351 → 5040 (-311 lines). New Style/StyleResolutionTrait.php: 335 lines.

Scope limited to HtmlTransformer.php + the new Style/ trait. Do not merge without review.

…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>
@chubes4 chubes4 merged commit 2e37e72 into trunk Jun 28, 2026
1 check passed
@chubes4 chubes4 deleted the refactor/htmltransformer-style-resolution branch June 28, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant