Skip to content

types(runtime-dom): allow null native attribute values (fix #8600) - #15240

Open
KasraK2K wants to merge 2 commits into
vuejs:mainfrom
KasraK2K:fix/8600-null-dom-attributes
Open

types(runtime-dom): allow null native attribute values (fix #8600)#15240
KasraK2K wants to merge 2 commits into
vuejs:mainfrom
KasraK2K:fix/8600-null-dom-attributes

Conversation

@KasraK2K

@KasraK2K KasraK2K commented Aug 8, 2026

Copy link
Copy Markdown

Summary

  • allow null for native HTML, SVG, and ARIA binding values
  • apply nullability at the NativeElements boundary so component prop contracts remain unchanged
  • add declaration tests for global, ARIA, boolean, and SVG attributes

Root cause

Vue removes or resets native DOM attributes and properties when their runtime value is null, but NativeElements exposed the underlying attribute types without including null. Template tooling and TSX therefore rejected values that the runtime supports.

Validation

  • reproduced the original TS2322 errors on main for id, aria-label, disabled, and viewBox
  • pnpm run build-dts
  • pnpm run test-dts-only
  • pnpm run check
  • ESLint and Prettier checks for the changed files

Closes #8600.

Summary by CodeRabbit

  • Bug Fixes
    • Updated JSX typing so null is accepted for native element properties, including ARIA attributes, input boolean attributes, and SVG attributes.
    • Improved type compatibility when using nullable values with intrinsic elements.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f39f955-7115-4e4a-a44d-6c4808b3bb70

📥 Commits

Reviewing files that changed from the base of the PR and between 8f89be8 and 0509083.

📒 Files selected for processing (2)
  • packages-private/dts-test/tsx.test-d.tsx
  • packages/runtime-dom/src/jsx.ts

📝 Walkthrough

Walkthrough

The runtime DOM JSX declarations now allow null for intrinsic element properties. Type tests cover HTML, ARIA, boolean, and SVG attributes.

Changes

Nullable JSX Native Props

Layer / File(s) Summary
Nullable native property mapping and validation
packages/runtime-dom/src/jsx.ts, packages-private/dts-test/tsx.test-d.tsx
NativeElementProps<T> maps intrinsic properties to their original type plus null. JSX tests validate null for div, input, and SVG attributes.

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

Possibly related PRs

  • vuejs/core#12771: Both changes broaden JSX attribute property types; that PR adds undefined, while this PR adds null.

Suggested labels: scope: types, :hammer: p3-minor-bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 runtime-dom type change and references the related issue.
Linked Issues check ✅ Passed The changes allow null for native HTML, SVG, and ARIA attributes and add declaration tests, satisfying issue #8600.
Out of Scope Changes check ✅ Passed All changes support native attribute nullability and its type coverage; no unrelated code changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@KasraK2K
KasraK2K marked this pull request as ready for review August 8, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

null binding value triggers type error in DOM attributes

2 participants