Skip to content

fix: trim only when necessary if trimming is off #394

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

Merged
merged 9 commits into from
Dec 18, 2021

Conversation

vidhu
Copy link
Contributor

@vidhu vidhu commented Dec 14, 2021

Fixes #384

What is the motivation for this pull request?

Fixes an issue #384 where trimming can lead to inaccurate parsing when nodes have whitespace characters

What is the current behavior?

  • if trim is off, whitespace characters trigger reacts validation errors
  • if trim is on, whitespaces are stripped from nodes that can contain white spaces which results in inaccurate parsing

What is the new behavior?

Regardless of the trimming setting, if a text node appears in a node that can contain text nodes eg <table>, <tr>, it will be removed. If trimming is off, then whitespaces are preserved in nodes that can contain text nodes.

Checklist:

Looking for approvals before I add to documentation!

@vidhu vidhu changed the title Fix/trimming issue Trim only when necessary if timing is off Dec 14, 2021
@vidhu vidhu changed the title Trim only when necessary if timing is off Trim only when necessary if trimming is off Dec 14, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2021

Codecov Report

Merging #394 (4126592) into master (ec61f9e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #394   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          158       162    +4     
  Branches        55        54    -1     
=========================================
+ Hits           158       162    +4     
Impacted Files Coverage Δ
lib/dom-to-react.js 100.00% <100.00%> (ø)
lib/utilities.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec61f9e...4126592. Read the comment docs.

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

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

Left comments

@remarkablemark remarkablemark added the bug Something isn't working label Dec 15, 2021
@vidhu
Copy link
Contributor Author

vidhu commented Dec 15, 2021

Left comments

Thank you! I've resolved the ones I've fixed and replied to your other comments

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

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

Looks good! Will you be updating docs @vidhu?

@vidhu
Copy link
Contributor Author

vidhu commented Dec 16, 2021

Looks good! Will you be updating docs @vidhu?

Yes! Just pushed out a commit to update the docs.

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

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

Left comments

@vidhu vidhu force-pushed the fix/trimming-issue branch from f5af355 to 4126592 Compare December 18, 2021 05:09
@vidhu
Copy link
Contributor Author

vidhu commented Dec 18, 2021

Thank you @remarkablemark I've addressed your requested changes

Copy link
Owner

@remarkablemark remarkablemark left a comment

Choose a reason for hiding this comment

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

Thanks, looks good @vidhu!

@remarkablemark remarkablemark changed the title Trim only when necessary if trimming is off fix: trim only when necessary if trimming is off Dec 18, 2021
@remarkablemark remarkablemark merged commit 3684196 into remarkablemark:master Dec 18, 2021
@remarkablemark
Copy link
Owner

Released in #395 (comment)

@vidhu
Copy link
Contributor Author

vidhu commented Dec 20, 2021

Thank you! Pleasure working with you :)

@remarkablemark
Copy link
Owner

Same here! @vidhu If you're ever interested in being a maintainer for html-react-parser, I'd be happy to extend the offer.

@vidhu
Copy link
Contributor Author

vidhu commented Dec 21, 2021

Thank you. I would be interested in that. Do you use any instant messaging platform like discord?

@remarkablemark
Copy link
Owner

Yes! We have a Discord server, feel free to DM me once you join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only trim nodes if parent can't contain text nodes
3 participants