Skip to content

fix(dom): set custom element props as properties - #36

Open
letstri wants to merge 1 commit into
TanStack:mainfrom
letstri:fix/custom-element-properties
Open

fix(dom): set custom element props as properties#36
letstri wants to merge 1 commit into
TanStack:mainfrom
letstri:fix/custom-element-properties

Conversation

@letstri

@letstri letstri commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

React 19 assigns a prop on a dashed tag as a property whenever the element declares one, and only writes an attribute otherwise. setProp had no such branch: every prop outside the IDL allowlist became an attribute, so an object value reached a web component as the string "[object Object]".

Components whose API is a property — <number-flow-react data={...}> — took their value only from whatever the library assigned itself on mount and never saw another update.

The other dashed names React excludes are SVG elements, already ruled out by isSvg; annotation-xml is the one that reaches here through MathML.

Budgets move with the measured cost: ~30-60 B gzip on the dist bundles.

Summary by CodeRabbit

  • Bug Fixes

    • Custom elements with dashed names now receive declared properties directly, preserving object and function values instead of converting them to strings.
    • Property updates are applied consistently across repeated renders.
    • Undeclared, data-*, and aria-* values continue to use attributes, while SVG and MathML behavior remains unchanged.
  • Documentation

    • Added release notes describing improved custom-element property handling.

React 19 assigns a prop on a dashed tag as a property whenever the element
declares one, and only writes an attribute otherwise. setProp had no such
branch: every prop outside the IDL allowlist became an attribute, so an
object value reached a web component as the string "[object Object]".

Components whose API is a property — `<number-flow-react data={...}>` — took
their value only from whatever the library assigned itself on mount and never
saw another update.

The other dashed names React excludes are SVG elements, already ruled out by
`isSvg`; `annotation-xml` is the one that reaches here through MathML.

Budgets move with the measured cost: ~30-60 B gzip on the dist bundles.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jb4ndC7Q2e5LUYo4DdXpZ4
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 8c4e0a88-1807-4002-987f-13668632eec8

📥 Commits

Reviewing files that changed from the base of the PR and between ae632f0 and 632f2ce.

📒 Files selected for processing (4)
  • .changeset/custom-element-properties.md
  • packages/redact/src/dom/dom.ts
  • scripts/size-check.mjs
  • tests/custom-element-props.test.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

setProp now assigns declared properties on dashed custom elements while preserving attribute handling for other props and namespaces. Tests cover property references, fallbacks, repeated updates, and SVG/MathML cases. A changeset and updated client bundle budgets support the change.

Changes

Custom element property assignment

Layer / File(s) Summary
Property assignment and regression coverage
packages/redact/src/dom/dom.ts, tests/custom-element-props.test.tsx
Dashed non-SVG custom elements receive declared properties directly. Undeclared, data-*, and aria-* props use attributes. Tests cover repeated updates and SVG/MathML handling.
Release metadata and bundle budgets
.changeset/custom-element-properties.md, scripts/size-check.mjs
The changeset documents the patch release. Related client bundle size budgets increase to account for the implementation.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: tannerlinsley

Merge Risk: ⚪ Minimal · up to 632f2

The custom-element update behavior is covered through the actual Redact rendering path, with no remaining actionable merge risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: assigning custom element props as properties.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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