Repository navigation
fix(core): restore the css value when a local style value is reset - #11520
Merged
Merged
Conversation
A CssProperty holds one value per style, so a local value took the slot the cascade had written. Resetting it (unsetValue, a css-wide keyword or '') fell back to the property default, and the css value only came back the next time the view's css state was re-applied. A local reset now falls back to the value the view's CssState last resolved for the property, which it records even while a local value suppresses the write, and only to the default (or, for inherited properties, the parent's value) when no rule sets it. The lookup happens on the reset path only.
|
View your CI Pipeline Execution ↗ for commit 06f1161
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
test_value_Local_stronger_than_Css asserted that style.color is undefined after a local unsetValue, even though a css rule applies. That was the transient value the next css re-apply overwrote; a reset now restores the css value immediately.
edusperoni
marked this pull request as ready for review
October 12, 2026 18:26
4 of 5 tasks
NathanWalker
approved these changes
Oct 23, 2026
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.
PR Checklist
What is the current behavior?
CssPropertyandInheritedCssPropertykeep a single value per style. A local value suppresses the css write and takes that slot, so resetting the local value (unsetValue,'unset'/'initial'/'inherit'/'revert', or'') falls back to the property default (or, for inherited properties, the parent's value) even when a matching css rule sets the property:The css value only comes back the next time the view's
CssStatere-applies (a dynamic state change or a re-match, via the_isCssValueStillAppliedcheck from #11371). Until then the view shows the wrong value.What is the new behavior?
A local reset falls back to the value the view's
CssStatelast resolved for the property. The cascade already records that value in_appliedPropertyValueseven while a local value suppresses the write. The value is written with sourceCss. The property only goes back to the default, or the inherited value, when no rule sets it. This works the same way for:CssPropertylocal resets (setLocalValue).InheritedCssPropertylocal resets. The css value wins over the parent's value, and children that inherit get the restored value.ShorthandProperty, which works through its longhands' local setters.CssState._getAppliedPropertyValue(property)exposes the recorded value. The bag already holds evaluated values (css variables,calc(), expanded shorthands), so nothing is re-parsed. The lookup only happens on the reset path, and the set path does no extra work.Native updates work as before: the restored value goes through the normal set path. That path covers
_suspendNativeUpdatesCount/_suspendedUpdates, capturingdefaultValueKey,valueChanged,equalityComparer,affectsLayoutand the change event. The change event'soriginstays'script', because a script write caused it. Only css-originated resets keep the old behavior. At that point the recorded value is the one being removed.Classes that are not affected:
CssAnimationPropertyalready keeps a separate slot per source (css/local/keyframe) and falls back on reset.Property/CoercibleProperty/InheritedProperty(view-level) don't track a css source. Css and local writes overwrite each other, so a local write never suppresses a css one.A small behavior change: a local
'initial'/'inherit'now also returns the property to the css value, if there is one. That matches what the next re-apply already did, since these keywords release the local value instead of storing it.Related but separate: #11413 fixes the descendant reset cascade of the view-level
InheritedProperty. That is a different class in the same file, and the two patches apply independently of each other.Tests:
packages/core/ui/core/properties/css-property-local-reset.spec.ts(17 cases). It covers the reset keywords, resets through the view, shorthand-sourced andvar()-sourced values, a local value set before css ran, the default and inherited fallbacks when no rule applies, native writes (css value vs captured native default), the change event, and propagation to inheriting children. 14 of them fail onmain, and the fullnx test coresuite passes with the fix.Updated existing test:
VALUE-SOURCE.test_value_Local_stronger_than_Cssassertedstyle.color === undefinedafter a localunsetValuewhilebutton { color: red }applied. That was the transient value the next CSS re-apply overwrote; it now expects the CSS red right away. The part the test is named for (a local value beats CSS) is still asserted just before.