-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix/TR-3995/Max words restriction can be exceeded #145
Fix/TR-3995/Max words restriction can be exceeded #145
Conversation
…to account, also refactor the helper
Version
There are 0 BREAKING CHANGE, 0 feature, 3 fixes |
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.
Review Checklist
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
- Pull request's target is not
master
- Commits are following conventional commits
- Commits messages are meaningful
- Commits are atomic
- Changelog is updated according to changes (if applicable)
- Documentation is updated according to changes (if applicable)
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.
Code looks fine and tests run well, please check my comment on optional change
* @param {Node} fragment | ||
*/ | ||
const limitFragment = fragment => { | ||
[].slice.call(fragment.childNodes).forEach(node => { |
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.
nitpick: may be we can rely on ES6 equivalent Array.from()
here?
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.
Indeed, I was considering using it. But as there might be a need to backport it to an older version than needs IE support I preferred to stay safe.
QA verified |
1/4
Related to: https://oat-sa.atlassian.net/browse/TR-3995
The helper
util/strLimiter
is aimed at limiting a text to a maximum number of units, either chars or words. Unfortunately, so far it was exclusively expecting plain text and it was producing wrong results with HTML.This pull request proposes to support either plain text or HTML text.
How to test:
Without the fix, the limit can be overflown.
With the fix, we cannot overflow the limit.