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

Highlights fail to merge when separated by a space #6

Open
findzen opened this issue Jun 6, 2014 · 1 comment
Open

Highlights fail to merge when separated by a space #6

findzen opened this issue Jun 6, 2014 · 1 comment

Comments

@findzen
Copy link

findzen commented Jun 6, 2014

Steps to reproduce:

  1. Given string "Lorem ipsum", highlight "Lorem"
  2. Highlight "ipsum" using same color
  3. Highlight "Lorem ipsum"

The space is not highlighted and therefore the highlights are not merged. Removing the regex check seems to solve this: https://github.com/mir3z/jquery.texthighlighter/blob/master/src/jquery.textHighlighter.js#L193

Was there another reason for this test? Given the node type has already been verified as text, wouldn't node.nodeValue always be a string?

@JoobyPM
Copy link

JoobyPM commented Aug 22, 2014

This bad idea. As result you will have a lot of "blank" spans (with any of those characters \f\n\r\t\v\u00A0\u2028\u2029) - it will be bad for html structure.
I had problem with "a new line character", when try to highlight the table.
Better modify condition:
/\S/.test(node.nodeValue) || node.nodeValue.length ==1

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

No branches or pull requests

2 participants