Skip to content

fix(svg): remove mask references to unstyled CSS masks - #540

Open
EnesKartal wants to merge 1 commit into
kepano:mainfrom
EnesKartal:fix/svg-unstyled-mask
Open

EnesKartal wants to merge 1 commit into
kepano:mainfrom
EnesKartal:fix/svg-unstyled-mask

Conversation

@EnesKartal

Copy link
Copy Markdown
Contributor

Fixes #532

Summary

  • Added removeUnstyledMaskReferences in src/standardize.ts (called from applySvgFallbackStyles when no inline <style> is present) to remove mask="url(#...)" attributes from SVG elements whose referenced <mask> has descendants with no inline fill or stroke (which would otherwise render as an all-black mask and hide the element).
  • Preserves mask attributes when the referenced <mask> has inline fill or stroke on its content.
  • Added a regression test in tests/svg-sanitization.test.ts.

Verification

  • npx vitest run tests/svg-sanitization.test.ts tests/markdown.test.ts (2 test files, 60 tests passed)
  • npm run lint:unused (passed)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG elements under a CSS-styled mask disappear

1 participant