-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fiber] Nesting validation warnings #8586
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,25 +15,20 @@ | |
var React = require('React'); | ||
|
||
var warning = require('warning'); | ||
var didWarnInvalidOptionChildren = false; | ||
|
||
function flattenChildren(children) { | ||
var content = ''; | ||
|
||
// Flatten children and warn if they aren't strings or numbers; | ||
// invalid types are ignored. | ||
// We can silently skip them because invalid DOM nesting warning | ||
// catches these cases in Fiber. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a bit easier to keep nesting checks in |
||
React.Children.forEach(children, function(child) { | ||
if (child == null) { | ||
return; | ||
} | ||
if (typeof child === 'string' || typeof child === 'number') { | ||
content += child; | ||
} else if (!didWarnInvalidOptionChildren) { | ||
didWarnInvalidOptionChildren = true; | ||
warning( | ||
false, | ||
'Only strings and numbers are supported as <option> children.' | ||
); | ||
} | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaearon This doesn't seem right. If I'm rendering SVG into an SVG tree, then the current namespace isn't HTML and the tag name isn't enough to determine it since I could be rendering into any SVG root. It seems to me that we should be reading the namespace of the root instead of the tagName.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#8638