Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cleanupIds changes style IDs incorrectly #1956

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

johnkenny54
Copy link
Contributor

If a style references 2 ids (e.g., fill:url(#c);stroke:url(#b);), and the IDs were changed so that c=>b and b=>a, cleanupIds was only changing the first element in the style twice.

This was very unlikely to happen on the first pass (regression results were unchanged), but common on subsequent passes (with multipass, regression results went from 467 failures and 199,877 pixel mismatches before the fix to 128 failures and 6,337 pixel mismatches after.

This PR fixes the issue by changing all references in the style at once. This required some rearranging and additional bookkeeping, in particular:

  • new IDs need to be generated before starting the replacement, since they all need to be available to the style replacement code
  • we need to keep track of which elements have had their styles updated so we don't try to update them again when the element is visited again

@johnkenny54 johnkenny54 marked this pull request as ready for review February 9, 2024 16:00
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.

None yet

1 participant