Server render writes style="" for an empty style object
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- web-dev
調査の方向性
Start with styleToString and attrToHtml in the server rendering code, which decide when a style attribute is written. Add the skip for true, false and '', and omit the attribute when nothing renders. Add the failing case to tests/ssr.test.tsx, then run pnpm test:ci. The size budget also needs SSR_STYLE_SIZE_ALLOWANCE in scripts/size-check.mjs approved by a maintainer before the change can merge.
索引モデルが issue の本文から書いたものです。
説明
renderToString(<div style={{}} />) returns <div style=""></div>; React returns <div></div>. Under a CSP without 'unsafe-inline' for styles, the browser reports each empty style="" as a violation.
Redact also writes style values that React skips:
style |
React 19.3.1 | Redact main |
|---|---|---|
{} |
<div></div> |
<div style=""></div> |
{ color: true } |
<div></div> |
<div style="color:true;"></div> |
{ color: '' } |
<div></div> |
<div style="color:;"></div> |
{ color: 'red', width: '' } |
<div style="color:red"></div> |
<div style="color:red;width:;"></div> |
React's pushStyleAttribute skips null, boolean and '' values, and writes style=" only before the first value that renders (react-dom-server.node.development.js:1186, react-dom 19.3.1).
Fix
Branch with the fix and tests, ready to merge (I can't open a PR here): https://github.com/TanStack/redact/compare/main...WolfieLeader:redact:fix/ssr-empty-style
What changes
styleToStringskipstrue,falseand''as well asnullandundefined.attrToHtmlwrites nostyleattribute when nothing renders.
Size
redact/server grows 18 B gzip in source and 16 B built, 7 B and 4 B over its budget. SSR_STYLE_SIZE_ALLOWANCE in scripts/size-check.mjs holds that measured increment and needs your approval. An empty-attribute-only fix still goes 2 B over in source.
Testing
- The new case in
tests/ssr.test.tsxfails onmainand passes with the fix. pnpm test:cipasses on Node 24.22.0.
- 主要言語
- TypeScript
- スター
- 640
- フォーク
- 32
- 平均マージ
- 1時間 15分
- マージ済み PR(30日)
- 7
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/redact のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
TanStack/redact#195 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
TanStack/redact#142 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
TanStack/redact の issue をすべて見る
似ている issue
-
bug data-types
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
ClickHouse/clickhouse-js#1293 ·
メンテナーはふだん 1 日以内に返信
-
area: middleware enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
agent/quality testing
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 1 日以内に返信
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 92/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
juspay/agent-distro#203 ·
メンテナーはふだん 1 日以内に返信