SVG: vectorEffect breaks hydration, and streamed Suspense inside <svg> lowercases attributes
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- react, typescript
- Domínio
- frontend
Direção de pesquisa
Start with attributeName() in packages/redact/src/core/attributes.ts, which only hyphenates clip, fill and stroke props, so vectorEffect needs mapping to vector-effect. The streaming gap is separate: the boundary content is walked without SVG context, and the <div> placeholder breaks out of <svg>, so the Suspense path needs its own investigation. Done means server HTML keeps vector-effect and preserveAspectRatio, and hydration inside <svg> matches React. Related PRs #96 and #103 overlap these paths, so check them first.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Version: @tanstack/redact 0.2.3 and main (37c051c). Baseline: react / react-dom 19.3.1. Browser: headless Chrome 154.
preserveAspectRatio and vectorEffect were both lowercased up to 0.2.0. #76 fixed the common preserveAspectRatio case in 0.2.1, but two gaps remain, and React handles both correctly.
| Path | preserveAspectRatio |
vectorEffect |
|---|---|---|
renderToString |
Correct | Emits vectorEffect (React emits vector-effect) |
| After Chrome parses that HTML | Correct | Becomes vectoreffect, ignored |
| Hydration | Clean, server nodes kept | Mismatch, server <main> replaced |
createRoot |
Correct, including updates | vectorEffect, ignored |
Streamed Suspense directly inside <svg> |
preserveaspectratio, ignored |
vectoreffect, ignored |
Without an onRecoverableError handler, the hydration failure logs nothing.
1. vectorEffect is never mapped to vector-effect, and this breaks hydration
attributeName() in packages/redact/src/core/attributes.ts only hyphenates SVG props starting with clip, fill or stroke, so vectorEffect passes through unchanged. On the client the browser ignores it. On the server, the HTML parser lowercases it to vectoreffect because it isn't a known SVG attribute name. Hydration then looks up vectorEffect, doesn't find it, and discards the boundary:
Hydration mismatch on <path> for "vectorEffect".
const tree = h(Suspense, { fallback: null },
h('main', null,
h('svg', null, h('path', { d: 'M0 0L9 9', vectorEffect: 'non-scaling-stroke' }))))
The computed vector-effect is none under Redact and non-scaling-stroke under React. This differs from what #81 describes for presentation attributes ("hydration reports nothing"): in a real browser, the parser's lowercasing makes hydration fail for this prop.
Workaround: style={{ vectorEffect: 'non-scaling-stroke' }} renders correctly and hydrates cleanly.
2. Streamed Suspense directly inside <svg> loses the SVG context
// Late suspends until after the shell has flushed
h('main', null,
h('svg', { viewBox: '0 0 9 9' },
h(Suspense, { fallback: null }, h(Late))))
// Late renders <symbol preserveAspectRatio="none" />
Redact emits:
<svg viewBox="0 0 9 9"><!--$?0--><div id="B:0"></div><!--/$--></svg>
...
<div hidden id="S:0"><symbol preserveaspectratio="none"></symbol></div>
- The boundary's content is walked with no SVG context, so
attributeName()takes its lowercase fallback. - The
<div>placeholder makes the HTML parser break out of the<svg>, and the segment is parsed in an HTML<div>. After reveal, the<symbol>is a child of<main>, in the HTML namespace.
Under React the same tree reveals inside the <svg>, in the SVG namespace, with preserveAspectRatio intact. A boundary outside the <svg> is unaffected under Redact, which is also the workaround.
Related
- #42: the original lowercasing report. Its
preserveAspectRatiocase is fixed outside streaming. - #81 / #96: the wider set of SVG presentation attributes. From reading the diff, #96 would also map
vectorEffect. I haven't run it. - #103: streamed insertion context for tables, SVG and MathML. From reading the diff, it targets the second gap. I haven't run it, and it currently has merge conflicts.
- Linguagem predominante
- TypeScript
- Estrelas
- 640
- Forks
- 32
- Merge médio
- 1h 15min
- PRs com merge (30d)
- 7
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/redact
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TanStack/redact#195 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/redact#142 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/redact
Issues semelhantes
-
bug data-types
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
ClickHouse/clickhouse-js#1293 ·
Mantenedores costumam responder em até 1 dia
-
area: middleware enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
agent/quality testing
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 95/100
Mantenedores costumam responder em até 1 dia
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
juspay/agent-distro#203 ·
Mantenedores costumam responder em até 1 dia