Repository navigation
SVG: read style declarations marked !important - #2172
Merged
Merged
Conversation
andersonhc
requested changes
Nov 12, 2026
andersonhc
left a comment
Collaborator
There was a problem hiding this comment.
I noticed one precedence case worth covering: fill:red !important; fill:blue currently renders blue, both in an inline style and inside a class rule. Red should win, but html.parse_css_style() collapses duplicate declarations before the importance checks run.
Could we resolve duplicates while their !important flags are still available and add regression tests for both forms?
html.parse_css_style() keeps the last declaration of a property, so "fill: red !important; fill: blue" lost red before the importance checks ran, in a style attribute as in a class rule.
Author
|
Good catch. Duplicate declarations are now resolved while their |
andersonhc
approved these changes
Nov 12, 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.
A style declaration with
!importantfails:Mermaid writes the
styleof a node this way: astyle A fill:#f9fstatement in a diagram givesstyle="fill:#f9f !important"on its shapes.The
!importantflag is now removed from the declarations ofstyleattributes and of<style>rules. As in CSS, an!importantdeclaration of a<style>rule wins over a normalstyleattribute, and over a later rule for the same class; an!importantstyleattribute still wins.Added a
style with !importantcase totest_svg_attribute_conversionandtest_svg_css_importantfor the order of the rules and thestyleattribute; 4 of the 5 cases fail on master. The SVG tests, black, pylint and mypy pass