[Repo Assist] Fix HtmlElement SVG serialisation: LinearGradient/RadialGradient emitted invalid tag (radient)#1108
Conversation
…emitted wrong tag name 'radient' Both LinearGradient and RadialGradient cases in HtmlElement.ToString() were passing the literal string "radient" to the format helper instead of "linearGradient" and "radialGradient" respectively. This meant that any SVG element using these types would render as the invalid tag <radient> in generated HTML. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/repo-assist can you explain where this is happening? What would the user do to hit this codepath? |
|
✗ Repo Assist encountered failed at {run-ended}. |
|
/repo-assist can you explain where this is happening? What would the user do to hit this codepath? |
|
✓ Repo Assist completed successfully at {run-ended}. |
|
🤖 This is an automated response from Repo Assist. Great question! Here's a breakdown: Where it happens
How a user hits it
open FSharp.Formatting.HtmlModel.Html
let gradientDef =
defs [] [
linearGradient [ Id "grad1" ] [
stop [ Style "stop-color:rgb(255,255,0);stop-opacity:1" ] []
stop [ Style "stop-color:rgb(255,0,0);stop-opacity:1" ] []
]
]
let chart =
svg [ Width "300"; Height "200" ] [
gradientDef
rect [ Fill "url(#grad1)"; Width "300"; Height "200" ] []
]
printfn "%s" (chart.ToString())
// Before fix: emits <radient ...> tags → invalid SVG, gradient silently ignored by browser
// After fix: emits <linearGradient ...> tags → correct SVGUsage in practiceNeither
|
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fix a typo in
HtmlElement.ToString()that causedLinearGradientandRadialGradientto emit the invalid SVG tag(radient)instead of the correct(linearGradient)and(radialGradient).Root Cause
In
HtmlModel.fs, thehelpermatch expression delegates to aformathelper by passing the tag name as a string literal. BothLinearGradientandRadialGradientcases were passing"radient"instead of"linearGradient"and"radialGradient"respectively:This is a pure typo — both branches accidentally shared the string
"radient"instead of the full SVG tag names.Impact
Any code that builds an
HtmlElement.LinearGradientorHtmlElement.RadialGradienttree and serialises it to a string (viaToString()or the Razor template pipeline) would produce(radient)elements, which are invalid SVG and would be silently ignored by browsers.Changes
src/FSharp.Formatting.Common/HtmlModel.fsLinearGradientandRadialGradientRELEASE_NOTES.md[Unreleased]changelog entryTest Status
dotnet build FSharp.Formatting.sln --configuration Release— succeeded (1 pre-existing FS0760 warning, unchanged)dotnet test tests/FSharp.Markdown.Tests— 281/281 passeddotnet fantomas src/FSharp.Formatting.Common/HtmlModel.fs --check— no formatting issues