Skip to content

Fix repeated SVG gradient disposal - #884

Merged
jonobr1 merged 2 commits into
jonobr1:devfrom
snowyukitty:fix/shared-gradient-disposal
Oct 31, 2026
Merged

jonobr1 merged 2 commits into
jonobr1:devfrom
snowyukitty:fix/shared-gradient-disposal

Conversation

@snowyukitty

Copy link
Copy Markdown
Contributor

Related to #847.

After an SVG gradient has been rendered, a second dispose() call throws because its element no longer has a parent. This also interrupts Path, Text, and Points disposal when the same gradient is used for both fill and stroke.

Check that the SVG element still has a parent before removing it. Keep the cached element and its stops so rendering the gradient again preserves the existing behavior. Add regression coverage for linear and radial gradients: repeated disposal, already-detached elements, and identical fill/stroke on all three shape types.

This addresses the repeated-disposal part of #847; ownership of a gradient shared by separate shapes remains unresolved.

Validation on e8a637bd:

  • npm run build, npm run lint, npm run types:check, npm run docs:generate, and npm run docs:build pass.
  • The browser disposal suite passes all 160 assertions. With only the new tests applied to the unchanged base, all 10 added scenarios fail on the null-parent removal.
  • Chromium rendering checks pass for linear and radial gradients in SVG, Canvas, and WebGL: repeated disposal followed by rendering preserves the pixels, and subsequent stop-color changes remain visible.
  • The complete browser suite reports 947 passing and 11 failing assertions, compared with 903 passing and the same 11 failures on the unchanged base: 10 image-rendering comparisons and one Two.Path.getBoundingClientRect expectation. No additional failures were introduced in this environment.

@snowyukitty
snowyukitty requested a review from jonobr1 as a code owner October 22, 2026 13:10
@jonobr1

jonobr1 commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Awww, thank you!

@jonobr1
jonobr1 merged commit 10e7b83 into jonobr1:dev Oct 31, 2026
4 checks passed
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.

2 participants