Skip to content
Source
Sign inSign up
TanStack/redact

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

Openletstri(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/36/headopened

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-*, and aria-* values continue to use attributes, while SVG and MathML behavior remains unchanged.
  • Documentation

    • Added release notes describing improved custom-element property handling.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 ae632f06d9ca785da78d57bc4d5a88e1f79b6c47 and 632f2cec59c954df8ff11b9f9db1e5208370dff7.


      📒 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

      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 817bc

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

      Pre-merge checks | Passed 4 | Failed 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring 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 nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title clearly and concisely describes the main change: assigning custom element props as properties.

      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.
    2. 🦋 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
      NameType
      @tanstack/redactPatch

      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.