Fix/css inherit shorthand resolution#203
Merged
FlorianRappl merged 1 commit intoAngleSharp:develfrom Mar 27, 2026
Merged
Conversation
The `inherit` keyword on shorthand properties like `border`, `margin`, and `padding` was not correctly resolved to parent values. Three independent bugs contributed: 1. DeclarationInfo: shorthand converters with null InitialValue were not wrapped with StandardValueConverter, so CSS-wide keywords like `inherit` were either ignored or partially mis-parsed by the property-specific converter. Fixed by always wrapping with StandardValueConverter first. 2. DeclarationInfoExtensions.Expand: CssInheritValue and CssUnsetValue were not handled when expanding shorthand properties to longhands, causing them to fall through to the aggregator Split which returned null. Added explicit handling for both value types. 3. DeclarationInfoExtensions.Collapse: CssInheritValue was not tracked for round-trip serialization of shorthand properties. Added inherit tracking alongside initial, unset, and child. 4. CssStyleDeclaration.ChangeDeclarations: when UpdateDeclarations found a child property with explicit `inherit` value, it removed it but did not allow the parent value to replace it because the skip flag was not reset. Fixed by setting skip to false when the old declaration is removed.
78b073e to
56102e0
Compare
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.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply:Description
Fix CSS inherit keyword not resolving on shorthand properties
The
inheritkeyword on shorthand properties likeborder,margin,and
paddingwas not correctly resolved to parent values. Threeindependent bugs contributed:
DeclarationInfo: shorthand converters with null InitialValue were
not wrapped with StandardValueConverter, so CSS-wide keywords like
inheritwere either ignored or partially mis-parsed by theproperty-specific converter. Fixed by always wrapping with
StandardValueConverter first.
DeclarationInfoExtensions.Expand: CssInheritValue and CssUnsetValue
were not handled when expanding shorthand properties to longhands,
causing them to fall through to the aggregator Split which returned
null. Added explicit handling for both value types.
DeclarationInfoExtensions.Collapse: CssInheritValue was not tracked
for round-trip serialization of shorthand properties. Added inherit
tracking alongside initial, unset, and child.
CssStyleDeclaration.ChangeDeclarations: when UpdateDeclarations
found a child property with explicit
inheritvalue, it removed itbut did not allow the parent value to replace it because the skip
flag was not reset. Fixed by setting skip to false when the old
declaration is removed.
fixes #184