Skip to content

Update HTML parser rules for new select parser#161

Closed
everettbu wants to merge 2 commits into
mainfrom
selectparser
Closed

Update HTML parser rules for new select parser#161
everettbu wants to merge 2 commits into
mainfrom
selectparser

Conversation

@everettbu
Copy link
Copy Markdown

@everettbu everettbu commented Dec 12, 2025

Mirror of facebook/react#34804
Original author: josepharhar


Summary

The HTML spec was updated to remove most special parsing rules for select elements: whatwg/html#10548

Chrome shipped these parser changes a while ago, and they have been implemented behind a flag in WebKit.

This PR updates the logic in validateDOMNesting to match the new HTML spec so that authors can use the new parsing rules without getting errors in React.

Fixes facebook/react#33609

How did you test this change?

I updated the test cases in validateDOMNesting-test.js

The HTML spec was updated to remove most special parsing rules for
select elements. This PR updates the logic in validateDOMNesting to
match the new HTML spec so that authors can use the new parsing rules
without getting errors in React.

Fixes facebook/react#33609
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Dec 12, 2025

Greptile Overview

Greptile Summary

Updated React's DOM nesting validation to align with the HTML spec's removal of special parsing rules for <select> elements (per whatwg/html#10548).

Key changes:

  • Removed restrictive parsing mode for select, optgroup, and option elements that previously only allowed specific children like hr, option, optgroup, script, template, and text nodes
  • Added select to inScopeTags array to match HTML spec's scope definition
  • Added validation to prevent <input> elements inside <select> (as input causes select tags to close per the spec)
  • Updated tests to reflect the new behavior, including allowing <div> inside <option> and complex nesting patterns like select > div > optgroup > div > option > span

This change enables developers to use modern HTML parsing behavior without validation warnings, as shipped in Chrome and implemented behind a flag in WebKit.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes correctly implement the HTML spec update by removing obsolete parsing restrictions. All modifications are well-tested with comprehensive test coverage, the logic is straightforward and mirrors the spec changes, and this aligns with browser implementations already shipped in Chrome and WebKit
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/react-dom-bindings/src/client/validateDOMNesting.js 5/5 Removed restrictive select/optgroup/option parsing rules per HTML spec update, added select to inScopeTags, added input validation to prevent it within select
packages/react-dom/src/tests/validateDOMNesting-test.js 5/5 Updated tests to reflect new parsing rules: added test for select>input validation, added value prop for option elements in test helper, added test for complex select nesting
packages/react-dom/src/tests/ReactDOMOption-test.js 5/5 Removed obsolete validation error tests for div children in option elements to align with new HTML spec

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@everettbu everettbu added Resolution: Stale Automatically closed due to inactivity and removed Resolution: Stale Automatically closed due to inactivity labels Feb 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions Bot added the Resolution: Stale Automatically closed due to inactivity label May 5, 2026
@github-actions
Copy link
Copy Markdown

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions Bot closed this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Resolution: Stale Automatically closed due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: validateDOMNesting needs to be updated for new customisable form widgets

2 participants