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

feat: add option trim #162

Merged
merged 7 commits into from
Jun 7, 2020
Merged

feat: add option trim #162

merged 7 commits into from
Jun 7, 2020

Conversation

remarkablemark
Copy link
Owner

What is the motivation for this pull request?

Feature: add option trim.

Resolves #155

What is the current behavior?

There is no way to remove whitespace text nodes.

What is the new behavior?

By passing option { trim: true }, whitespace text nodes are skipped:

parse('<br>\n', { trim: true }) // React.createElement('br')

This helps resolve the warning:

Warning: validateDOMNesting(...): Whitespace text nodes cannot appear as a child of <table>. Make sure you don't have any extra whitespace between tags on each line of your source code.

Checklist:

  • Tests
  • Documentation
  • Types

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 21190a3 on feat/option-trim into 4ef89af on master.

@@ -252,6 +252,32 @@ See [htmlparser2 options](https://github.com/fb55/htmlparser2/wiki/Parser-option

> **Warning**: By overriding htmlparser2 options, there's a chance of breaking universal rendering. Do this at your own risk.

### trim
Copy link
Owner Author

Choose a reason for hiding this comment

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

@remarkablemark remarkablemark merged commit 8a6589f into master Jun 7, 2020
@remarkablemark remarkablemark deleted the feat/option-trim branch June 7, 2020 20:31
@remarkablemark
Copy link
Owner Author

Published 0.13.0:

npm:

npm install [email protected]

yarn:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace text nodes cannot appear as a child of <table>
2 participants