-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
No whitespace warning #7081
No whitespace warning #7081
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 |
---|---|---|
|
@@ -327,8 +327,8 @@ if (__DEV__) { | |
var parentInfo = ancestorInfo.current; | ||
var parentTag = parentInfo && parentInfo.tag; | ||
|
||
var invalidParent = | ||
isTagValidWithParent(childTag, parentTag) ? null : parentInfo; | ||
var invalidParent = childInstance._isWhitespace ? | ||
null : isTagValidWithParent(childTag, parentTag) ? null : parentInfo; | ||
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. I think we should avoid nested ternary operator |
||
var invalidAncestor = | ||
invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo); | ||
var problematic = invalidParent || invalidAncestor; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,11 @@ var ReactDOMTextComponent = function(text) { | |
this._mountIndex = 0; | ||
this._closingComment = null; | ||
this._commentNodes = null; | ||
|
||
if (__DEV__) { | ||
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. @syranide - We now check for dev mode before adding this property |
||
// validateDOMNesting uses this: | ||
this._isWhitespace = typeof text === 'string' && text.trim().length === 0; | ||
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. Just curious, since this might be somewhat of a hot path. Have you benchmarked this against |
||
} | ||
}; | ||
|
||
Object.assign(ReactDOMTextComponent.prototype, { | ||
|
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.
Will skip valid parent check for all children deemed whitespace. Not just elements in
<table>