Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

hkal
Copy link
Contributor

@hkal hkal commented Jun 20, 2016

Resolves #6995

Includes some misc. lint fixes. Will squash if accepted.

cc @spicyj @jimfb

@@ -48,6 +48,7 @@ var ReactDOMTextComponent = function(text) {
this._mountIndex = 0;
this._closingComment = null;
this._commentNodes = null;
this._isWhitespace = typeof text === 'string' && text.trim().length === 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

text in this case is not ensured to be a string. I'm also not sure if adding a property here is the right move. Maybe the check should be done in validateDOMNesting.js?

Copy link
Contributor

Choose a reason for hiding this comment

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

We only care about this in DEV right?

Copy link
Contributor Author

@hkal hkal Jun 22, 2016

Choose a reason for hiding this comment

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

That's right. validateDOMNesting is a noop in production mode and, at the moment, it's the only place that cares about _isWhitespace.

Thanks for pointing that out, so this line should be changed to:

if (__DEV__) {
  this._isWhitespace = typeof text === 'string' && text.trim().length === 0;
}

Or did you have something else in mind?

@hkal hkal force-pushed the no-whitespace-warning branch from fba590a to 28614a6 Compare June 23, 2016 07:09
@@ -48,6 +48,11 @@ var ReactDOMTextComponent = function(text) {
this._mountIndex = 0;
this._closingComment = null;
this._commentNodes = null;

if (__DEV__) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@syranide - We now check for dev mode before adding this property

@ghost ghost added the CLA Signed label Jul 12, 2016
  * Identify if content of ReactDOMTextComponent is only whitespace
  * Fixed misc. lint errors
@hkal hkal force-pushed the no-whitespace-warning branch from 28614a6 to e35e2de Compare July 22, 2016 01:24
@ghost ghost added the CLA Signed label Jul 22, 2016
@hkal
Copy link
Contributor Author

hkal commented Jul 22, 2016

@gaearon We good on this or does it need more work?

@ghost ghost added the CLA Signed label Jul 22, 2016

if (__DEV__) {
// validateDOMNesting uses this:
this._isWhitespace = typeof text === 'string' && text.trim().length === 0;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 REGEX.test(text)? With REGEX being a constant and not inline.

@aweary
Copy link
Contributor

aweary commented Oct 4, 2016

@hkal can you resolve the merge conflicts? Thanks!

@sophiebits
Copy link
Collaborator

I already ended up fixing this in a different way in #7515. Thanks for sending this though!

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.

Relax validateDOMNesting warning for whitespace in table
7 participants