Skip to content

Only inherit gradient geometry through gradients of the same kind - #145

Closed
swhitty wants to merge 1 commit into
mainfrom
gradient-geometry-kind
Closed

swhitty wants to merge 1 commit into
mainfrom
gradient-geometry-kind

Conversation

@swhitty

@swhitty swhitty commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #143.

Per SVG 1.1 §13.2.2 and §13.2.3, geometry (x1…y2, cx…fr) is inherited only from gradients of the same kind. makeGradient skipped over other-kind links in the href chain, so a linear gradient referencing a radial gradient which referenced another linear gradient picked up the outer linear gradient's geometry.

Geometry is now read only from the leading run of same-kind gradients in the chain. Units, transform and stops still inherit across kinds.

Adds testLinearGradient_DoesNotInheritGeometry_ThroughDifferentKind, which fails without the fix.

Verified against resvg: for a linear → radial → linear chain where only the last gradient sets x1, resvg renders the same as when x1 is not set at all, i.e. geometry does not pass through the radial gradient. A direct linear → linear reference does inherit it.

A linear gradient referencing a radial gradient which references another
linear gradient no longer picks up x1...y2 from the outer linear gradient.
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.07%. Comparing base (408e8c5) to head (2ce42ee).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   89.05%   89.07%   +0.01%     
==========================================
  Files         167      167              
  Lines       13589    13607      +18     
==========================================
+ Hits        12102    12120      +18     
  Misses       1487     1487              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@swhitty

swhitty commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Closing: skipping other-kind links when resolving gradient geometry matches browsers and resvg (and #142), so the current behaviour on main is correct.

@swhitty swhitty closed this Nov 14, 2026
@swhitty
swhitty deleted the gradient-geometry-kind branch November 14, 2026 13:12
@swhitty
swhitty restored the gradient-geometry-kind branch November 14, 2026 13:14
@swhitty swhitty reopened this Nov 14, 2026
@swhitty

swhitty commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Reopening: I closed this on a wrong assumption. Rendering the mixed chain with resvg shows it stops geometry at the other-kind link, which is what this PR does.

@swhitty

swhitty commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Closing for good: rendering a linear → radial → linear chain (only the last sets x1) in Safari and Chrome inherits the geometry through the radial link, the same as the current behaviour on main and #142. resvg is the outlier here (it stops at the other-kind link), so main is the behaviour to keep.

@swhitty swhitty closed this Nov 14, 2026
@swhitty
swhitty deleted the gradient-geometry-kind branch November 14, 2026 13:19
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.

1 participant