Skip to content

Accept revert/revert-layer/unset on every property - #203

Merged
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/css-wide-keywords-revert-unset
Jul 23, 2026
Merged

Accept revert/revert-layer/unset on every property#203
TylerBrinks merged 1 commit into
TylerBrinks:masterfrom
jhaygood86:feature/css-wide-keywords-revert-unset

Conversation

@jhaygood86

Copy link
Copy Markdown
Contributor

Problem

revert, revert-layer and unset are rejected on most properties, while inherit and initial work:

color: unset;              /* rejected */
display: revert;           /* rejected */
white-space: revert-layer; /* rejected */
color: inherit;            /* fine */

All five are CSS-wide keywords, valid on every property (CSS Cascade 4 §7.3; revert-layer is Cascade 5).

OrGlobalValue already accepts all five, but the widely-used OrDefault accepts only inherit and initial:

public static IValueConverter OrDefault(this IValueConverter primary)
{
    return primary.OrInherit().Or(Keywords.Initial);   // no revert / revert-layer / unset
}

so any property converter built with OrDefault (the majority) rejects the other three.

Fix

Route OrDefault through OrGlobalValue, and extend the defaulted overload (OrDefault<T>) with the same three keywords. The Keywords.Revert/RevertLayer/Unset constants already exist.

Tests

15 cases in PropertyTests/GlobalKeywordPropertyTests.cs: all five keywords across color, display, text-align, float, white-space, font-weight, line-height; plus misspellings (reverts, un-set, revertlayer) that must stay rejected, confirming the accepted set widened without loosening the grammar.

12 fail on master. The full suite (1263 existing tests) stays green, and all seven target frameworks build with no new warnings.

inherit, initial, revert, revert-layer and unset are CSS-wide keywords,
valid on every property (CSS Cascade 4 7.3; revert-layer is Cascade 5).
OrGlobalValue already accepted all five, but OrDefault - which most
property converters use - accepted only inherit and initial, so
"color: unset", "display: revert" and "white-space: revert-layer" were
rejected while "color: inherit" worked.

Route OrDefault through OrGlobalValue, and extend the defaulted overload
with the same three keywords. Misspellings ("un-set", "revertlayer")
remain rejected.
@jhaygood86
jhaygood86 marked this pull request as ready for review July 22, 2026 22:34
@TylerBrinks
TylerBrinks merged commit e970433 into TylerBrinks:master Jul 23, 2026
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.

2 participants