validateDOMNesting warns when optional tags are missing
See original GitHub issueAccording to the HTML 5 spec, certain tags are optional in specific circumstances because their presence is implied. However, I’m getting warnings for these cases.
I imagine this complexity is not something worth accounting for within validateDOMNesting
, but I wanted to call it out just the same.
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
validateDOMNesting: #text cannot appear as a child of <tr ...
I wrapped my text with <td> elements and the warning disappeared. When I did this, having a whitespace in my text or having...
Read more ><div> cannot appear as a child of <table> - You.com - You.com
Warning : validateDOMNesting(...): Whitespace text nodes cannot appear as a child of <thead>. Make sure you don't have any extra whitespace between tags...
Read more >Change Log - Ant Design
Fix Space throws Encountered two children with the same key warning in some cases. #35311. Fix Select tag remove icon position issue.
Read more >Optional Tags in HTML 4 - Jens Oliver Meiert
IMHO, the most useful statement about optional tags is missing here: not to make use of the option of leaving them out (for...
Read more >antd/CHANGELOG.en-US.md - UNPKG
88, - Add en-GB missing translations for table. ... 165, - Fix Empty description validateDOMNesting warning.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@spicyj Thanks for the clarification - that’s helpful. In my case, the warnings are actually on neither
tbody
norcolgroup
. When rendering server-side, the app uses a fairly truncatedHtml
component that when thrown torenderToStaticMarkup
produces errors like the following:However, the following passes the w3’s validator and is rendered correctly because the
head
tag can be omitted here:So far, I’m only encountering a few warnings - and I’m ignoring them. Are you aware of problems this can cause in the React world?
I think we’ll close this. It’s not hard to type extra
tbody
by hand, and doing this implicitly can lead to surprises.