Skip to content

Stop a theme border overruling an explicit border width - #349

Open
sadiqk2 wants to merge 1 commit into
NativePHP:mainfrom
sadiqk2:fix/theme-border-width-precedence
Open

Stop a theme border overruling an explicit border width#349
sadiqk2 wants to merge 1 commit into
NativePHP:mainfrom
sadiqk2:fix/theme-border-width-precedence

Conversation

@sadiqk2

@sadiqk2 sadiqk2 commented Aug 17, 2026

Copy link
Copy Markdown

The bug

border-theme-* has to imply a width — without one a theme border is invisible — but it asserted borderWidth => 1 outright. TailwindParser::parse() merges each token's result in string order, so the implied width overwrote an explicit one whenever the theme class came second:

TailwindParser::parse('border-2 border-theme-primary');  // borderWidth => 1  ❌
TailwindParser::parse('border-theme-primary border-2');  // borderWidth => 2  ✅

Same two classes, same intent, different result depending on the order they were typed — and nothing on the device hints at why, since both classes are present and one of them silently wins.

The fix

A theme border now emits borderWidthDefault, and parse() collapses that into borderWidth at the very end, only when no class set one explicitly. The outcome no longer depends on order, and the internal key never reaches the parsed output — a bare border-theme-primary produces exactly what it produced before.

Verification

  • Three tests added to tests/Unit/Edge/ThemeClassTokensTest.php: both class orders, a bare theme border keeping its 1px, and the internal key never leaking into the output.
  • The precedence test fails against main and passes with this change.
  • vendor/bin/pest for the Edge suites: 114 passed. Full suite matches main's baseline — the 13 failures on both are in the Android splash-screen and release-build tests and are unrelated to this change.
  • vendor/bin/pint --test clean on both touched files.

border border-theme-outline pairs appear in super-native's own templates, so this affects the demo as well as apps.

`border-theme-outline` has to imply *a* width, or a theme border is invisible.
It asserted `borderWidth => 1` outright, so whether `border-2 border-theme-outline`
rendered 1px or 2px depended on which class came last in the string: `parse()`
merges each token's result in order, so the theme token overwrote the explicit
width when it came second, and lost to it when it came first.

The failure has no visible cause on a device — the classes are both there, in the
order the author wrote them, and one of them silently wins.

A theme border now emits `borderWidthDefault`, and `parse()` collapses that into
`borderWidth` at the end only if nothing else set one. The result is
order-independent and the key never reaches the output, so the renderers see
exactly what they saw before for a bare theme border.

This affects the super-native demo: `border border-theme-outline` combinations
appear in its own templates.
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