SVG presentation attributes (fontSize, stopColor, textAnchor…) reach the DOM in camelCase, so the browser ignores them
Maintainer antworten meist innerhalb von 1 Tag
@barrymichaeldoyle arbeitet bereits daran.
Seit 28.10.2026.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- react, typescript
- Bereich
- frontend
Rechercherichtung
Start by reading packages/redact/src/core/attributes.ts and trace how attributeName() handles SVG names; compare the reported React alias map at packages/react-dom-bindings/src/shared/getAttributeAlias.js. Check the related issue #42 for context. Done means SVG presentation attributes and xlinkHref serialize with the expected names while camelCase names such as clipPathUnits stay intact across SSR, client rendering, and hydration.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version: @tanstack/redact 0.2.1, attributeName() unchanged on main (20f6dd6b). Baseline: react / react-dom 19.3.1.
On SVG elements, attributeName() in packages/redact/src/core/attributes.ts kebab-cases only the props that start with clip, fill or stroke, and keeps every other name as written. React maps the camelCase presentation attributes to their hyphenated names, so under Redact fontSize, fontWeight, stopColor, textAnchor, markerEnd, xlinkHref and the rest reach the DOM in camelCase, and the browser ignores them. The prefix rule also fails the other way: clipPathUnits, which SVG spells in camelCase, becomes clip-path-units.
The server and the client produce the same markup, so hydration reports nothing: the SVG just draws wrong. We hit it on a logo whose word is a <text fontSize={58} fontWeight={500}>. Under Redact it renders at the inherited font size, and its gradient stops (stopColor) turn black.
Reproduction
npm i @tanstack/[email protected] [email protected] [email protected] jsdom, then node repro.mjs react and node repro.mjs redact:
// repro.mjs
import { JSDOM } from "jsdom"
const { window } = new JSDOM("<!doctype html><div id=root></div>")
Object.assign(globalThis, { window, document: window.document, HTMLElement: window.HTMLElement, Node: window.Node })
const redact = process.argv[2] === "redact"
const R = await import(redact ? "@tanstack/redact" : "react")
const { renderToString } = await import(redact ? "@tanstack/redact/server" : "react-dom/server")
const { createRoot } = await import(redact ? "@tanstack/redact/dom-client" : "react-dom/client")
const { flushSync } = await import(redact ? "@tanstack/redact/dom" : "react-dom")
const h = R.createElement
const App = () =>
h("svg", { viewBox: "0 0 100 20" },
h("linearGradient", { id: "g" }, h("stop", { offset: 0, stopColor: "#fff", stopOpacity: 0.5 })),
h("clipPath", { id: "c", clipPathUnits: "objectBoundingBox" }),
h("text", { x: 0, y: 16, fontSize: 16, fontWeight: 500, textAnchor: "start", dominantBaseline: "middle" }, "365"),
h("use", { xlinkHref: "#g", markerEnd: "url(#m)", vectorEffect: "non-scaling-stroke" }))
console.log("SSR: ", renderToString(h(App)))
const root = document.getElementById("root")
flushSync(() => createRoot(root).render(h(App)))
console.log("client:", root.innerHTML)
renderToString and createRoot give the same names, in each runtime:
| Prop | React 19.3.1 | Redact 0.2.1 |
|---|---|---|
stopColor, stopOpacity |
stop-color, stop-opacity |
stopColor, stopOpacity |
fontSize, fontWeight |
font-size, font-weight |
fontSize, fontWeight |
textAnchor, dominantBaseline |
text-anchor, dominant-baseline |
textAnchor, dominantBaseline |
markerEnd, vectorEffect |
marker-end, vector-effect |
markerEnd, vectorEffect |
xlinkHref |
xlink:href |
xlinkHref |
clipPathUnits |
clipPathUnits |
clip-path-units |
Each runtime's markup loaded in Chromium, inside a body set to font-size: 12px:
| Computed | React 19.3.1 | Redact 0.2.1 |
|---|---|---|
<text> font size, weight |
16px, 500 | 12px, 400 |
<stop> stop color |
rgb(255, 255, 255) |
rgb(0, 0, 0) |
clipPath.clipPathUnits |
objectBoundingBox | userSpaceOnUse |
Possible fix
React keeps an explicit alias map instead of a prefix rule (packages/react-dom-bindings/src/shared/getAttributeAlias.js): strokeWidth → stroke-width, fontSize → font-size, xlinkHref → xlink:href, and every name it doesn't list stays as written. Reusing that list in attributeName() would fix both directions. SSR, the client's setAttribute and hydration validation all go through that one function, so they would stay in sync.
Related: #42, about the same function lowercasing case-sensitive names (patternUnits).
- Vorherrschende Sprache
- TypeScript
- Sterne
- 640
- Forks
- 32
- Ø Merge
- 1 Std. 15 Min.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/redact
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
TanStack/redact#195 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/redact#142 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/redact
Ähnliche Issues
-
bug data-types
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area: middleware enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
agent/quality testing
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
Maintainer antworten meist innerhalb von 1 Tag
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
juspay/agent-distro#203 ·
Maintainer antworten meist innerhalb von 1 Tag