Skip to content

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

Merged
remarkablemark merged 9 commits intoremarkablemark:masterfrom
vidhu:fix/trimming-issue
Dec 18, 2021
Merged

fix: trim only when necessary if trimming is off#394
remarkablemark merged 9 commits intoremarkablemark:masterfrom
vidhu:fix/trimming-issue

Conversation

@vidhu
Copy link
Copy Markdown
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
Copy Markdown

codecov-commenter commented Dec 15, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ec61f9e) to head (4126592).
⚠️ Report is 2127 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #394   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          158       162    +4     
  Branches        55        54    -1     
=========================================
+ Hits           158       162    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

vidhu commented Dec 18, 2021

Thank you @remarkablemark I've addressed your requested changes

Copy link
Copy Markdown
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
Copy Markdown
Owner

Released in #395 (comment)

@vidhu
Copy link
Copy Markdown
Contributor Author

vidhu commented Dec 20, 2021

Thank you! Pleasure working with you :)

@remarkablemark
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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