Skip to content

chore: drop dead CSS declarations and deprecate no-op API - #85

Merged
NuPlay merged 1 commit into
mainfrom
chore/remove-dead-css-and-noop-api
Aug 29, 2026
Merged

chore: drop dead CSS declarations and deprecate no-op API#85
NuPlay merged 1 commit into
mainfrom
chore/remove-dead-css-and-noop-api

Conversation

@NuPlay

@NuPlay NuPlay commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Dead code found by auditing every member of RichTextConstants for real usage. None of this changes rendering.

Dead CSS

loading: lazy in imageCSS. loading is an HTML attribute, not a CSS property, so every browser dropped the declaration. It only ever looked like lazy loading was enabled; enabling it for real would mean setting the attribute on the <img> elements.

Percentage min-height/max-height in imageCSS. Both resolved against a containing block of auto height, so both were no-ops that contributed nothing to the responsive behaviour - which is why nobody noticed they were broken before #76. min-height: 100% in particular would have stretched every image to the full container height the moment a definite height appeared. max-width: 100% with height: auto is what actually does the work, and is what is left.

Wrong format specifier

iframeCSS used %d for iframeHeight, which is a Swift Int and therefore 64-bit on every platform this package supports, while %d reads 32 bits. It works for the current value of 250 and would silently not for a large one. Color+Extension already spells the same thing %02lX, so %ld matches the existing convention.

API that does nothing

bodyCSS is referenced nowhere. Body margins are emitted directly by cssTemplate and mediaCSSTemplate, which means its -webkit-text-size-adjust rule has never been applied either.

Configuration.isColorsImportant is recorded but never read during CSS generation. !important comes entirely from ColorSet.isImportant on fontColor/linkColor, so this silently did nothing:

Configuration(isColorsImportant: .all)   // no effect

Both are deprecated rather than deleted, since they are public API. The colour preference still round-trips through internal storage so behaviour is unchanged and the framework does not warn on its own API. .colorPreference(forceColor:) on the view, which sets both colour sets, is the working path and the deprecation message points at it.

A new test pins down which of the two paths actually reaches the CSS:

Configuration(fontColor: ColorSet(light: "000000", dark: "FFFFFF"), isColorsImportant: .all)
// -> no "#000000 !important"

Configuration(fontColor: ColorSet(light: "000000", dark: "FFFFFF", isImportant: true))
// -> "#000000 !important"

`imageCSS` declared `loading: lazy`. `loading` is an HTML attribute, not a CSS
property, so every browser dropped the declaration; it only ever looked like
lazy loading was enabled. Enabling it for real would mean setting the attribute
on the `<img>` elements.

`imageCSS` also carried percentage `min-height`/`max-height`. Both resolved
against a containing block of `auto` height, so they were no-ops that
contributed nothing to the responsive behaviour, and `min-height: 100%` would
have stretched every image to the full container height as soon as a definite
height appeared. `max-width: 100%` with `height: auto` is what does the work.

`iframeCSS` used `%d` for `iframeHeight`, which is a Swift `Int` and therefore
64-bit on every platform this package supports, while `%d` reads 32 bits. It
works for the current value of 250 and would silently not for a large one.
`Color+Extension` already spells the same thing `%02lX`, so `%ld` matches.

`bodyCSS` is referenced nowhere. Body margins are emitted directly by
`cssTemplate` and `mediaCSSTemplate`, which means its `-webkit-text-size-adjust`
rule has never been applied either.

`Configuration.isColorsImportant` is recorded but never read during CSS
generation - `!important` comes entirely from `ColorSet.isImportant` - so
passing `isColorsImportant: .all` silently did nothing.

Both are deprecated rather than deleted, since they are public API. Behaviour is
unchanged and the colour preference still round-trips through internal storage,
so the framework does not warn on its own API. A new test pins down which of the
two paths actually reaches the CSS.
Copilot AI lite review requested due to automatic review settings August 29, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@NuPlay NuPlay added the bug Something isn't working label Aug 29, 2026
@NuPlay NuPlay self-assigned this Aug 29, 2026
@NuPlay
NuPlay merged commit b51a391 into main Aug 29, 2026
1 check passed
@NuPlay
NuPlay deleted the chore/remove-dead-css-and-noop-api branch August 29, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants