Fix empty CSS declarations overriding presentation attributes#511
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2df855813
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This was referenced May 12, 2026
This was referenced May 20, 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.
Pull Request Summary
Summary
Fixes the regression reported in #231 where an SVG presentation attribute such as
fill="rgb(0,0,255)"was incorrectly overridden by an invalid empty CSS declaration such asstyle="fill:;".Browsers drop declarations with no value and continue applying later valid declarations in the same style block. The Svg.Skia compatibility CSS pipeline was instead forwarding empty declaration values into
SvgElement.AddStyle, which allowed the empty inline or stylesheet value to win over a valid presentation attribute and made the fill resolve as black.This change makes the compatibility pipeline ignore empty or whitespace-only declaration values in both places where CSS declarations are converted into SVG styles:
style="..."attributes handled bySvgInlineStyleAttributeParser.SvgCssCompatibilityProcessor.Valid declarations following an invalid empty declaration are still applied, matching browser behavior. For example,
style="fill:;stroke:white"now preserves the element's presentationfilland still applies the inlinestroke.Changes
style="fill:;"are skipped instead of added to the element style map.<style>elements are materialized for selector application.<style>stylesheet rules containing empty declarations.strokeafter an invalidfill:.Validation
dotnet test tests/Svg.Skia.UnitTests/Svg.Skia.UnitTests.csproj -f net10.0 -c Release --no-restore --filter "FullyQualifiedName~SvgDocumentCompatibilityLoaderTests"passed with 37 tests.dotnet build Svg.Skia.slnx -c Release --no-restoredotnet test Svg.Skia.slnx -c Release --no-restoreNotes
dotnet formatwas attempted during validation, but the formatter host did not return in this worktree for either solution-scoped or project-scoped invocations. The touched source and test changes are minimal and follow the surrounding style.