fix(dom): set custom element props as properties #36
main fromrefs/pull/36/head·opened 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.
The added bytes fit the existing size budgets on current main, so scripts/size-check.mjs is unchanged.
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-*, andaria-*values continue to use attributes, while SVG and MathML behavior remains unchanged.
Documentation
- Added release notes describing improved custom-element property handling.
- 1
🦋 Changeset detected#
Latest commit: 817bc8a95ef470a5ce8a71a2f50b5641a8ce728e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Name Type @tanstack/redact Patch Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Sign in to join this conversation.
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 ae632f06d9ca785da78d57bc4d5a88e1f79b6c47 and 632f2cec59c954df8ff11b9f9db1e5208370dff7.
📒 Files selected for processing (4)
.changeset/custom-element-properties.mdpackages/redact/src/dom/dom.tsscripts/size-check.mjstests/custom-element-props.test.tsxIncluded review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.
📝 Walkthrough
📝 Walkthrough
Walkthrough#
setPropnow 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
packages/redact/src/dom/dom.ts,tests/custom-element-props.test.tsxdata-*, andaria-*props use attributes. Tests cover repeated updates and SVG/MathML handling..changeset/custom-element-properties.md,scripts/size-check.mjsPriority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Suggested reviewers:
tannerlinsleyMerge Risk: ⚪ Minimal · up to
817bcThe 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)#
✅ Passed checks (4 passed)
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.)
✨ Finishing Touches
🧪 Generate unit tests (beta)
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