Skip to content

Fix !important declarations being overridden by non-important duplicates#199

Merged
FlorianRappl merged 1 commit intoAngleSharp:develfrom
jafin:fix/important-declaration-override
Mar 27, 2026
Merged

Fix !important declarations being overridden by non-important duplicates#199
FlorianRappl merged 1 commit intoAngleSharp:develfrom
jafin:fix/important-declaration-override

Conversation

@jafin
Copy link
Copy Markdown
Contributor

@jafin jafin commented Mar 27, 2026

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

In SetLonghand, a later non-important declaration for the same property would unconditionally replace an earlier !important one. Now the existing declaration is preserved when it is !important and the incoming one is not.

Fixes the issue where parsing style="padding: 20px !important; padding: 0"
would incorrectly yield "padding: 0" instead of keeping the important value.

Fixes #193

In SetLonghand, a later non-important declaration for the same property
would unconditionally replace an earlier !important one. Now the existing
declaration is preserved when it is !important and the incoming one is not.

Fixes the issue where parsing style="padding: 20px !important; padding: 0"
would incorrectly yield "padding: 0" instead of keeping the important value.
Copy link
Copy Markdown
Contributor

@FlorianRappl FlorianRappl left a comment

Choose a reason for hiding this comment

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

LGTM!

@FlorianRappl FlorianRappl added this to the v1.0 milestone Mar 27, 2026
@FlorianRappl FlorianRappl merged commit 586b888 into AngleSharp:devel Mar 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

!important does not take precedence over non-important declaration later in inline style

2 participants