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

sub string of searched strings are not getting highlighted #2

Open
kvijesh opened this issue Aug 19, 2011 · 4 comments
Open

sub string of searched strings are not getting highlighted #2

kvijesh opened this issue Aug 19, 2011 · 4 comments

Comments

@kvijesh
Copy link

kvijesh commented Aug 19, 2011

OS: Windows Vista
Chrome: 13.0.782.112
Url: http://blog.vijesh.in/2011/08/true-its-not-his-thing.html

Steps to reproduce

  • search for "everyone" (without quotes)
  • search "one"
  • search "every"
  • search "eryo" (I know its a crude test case, but there can be scenarios with the long names for methods and classes used)

"eryo" - does not get highlighted.

Expected, it should get highlighted.

But try searching "very" it would highlight. I'm guessing its not highlighting by grouping two already highlighted sections.

@psankar
Copy link
Owner

psankar commented Aug 19, 2011

Confirming the issue. I don't know of the cleanest solution possible atm.

@kvijesh
Copy link
Author

kvijesh commented Aug 19, 2011

Same is the case if I try highlighting an already highlighted section and non-highlighted section.

HelloWorld

search "hello" - will highlight fine
search "helloworld" - no change

@varunkumar
Copy link
Collaborator

There are serious problems with the jQuery Highlighter plugin. It needs to be re-written if sophisticated features are to be added to this extension.

@varunkumar
Copy link
Collaborator

This is what is happening:

  • When you search for "Everyone", the highlight plug-in does DFS on DOM tree starting from document.body. If a match is found in the text node "Everyone", the plug-in surrounds it with a tag to highlight. Hence, it becomes an element node. <span...>EveryOne
  • Search of "Every". DFS will reach the new element node and it will go further into the text node "EveryOne" and now DOM will look like this: <span..><span..>EveryOne. Every & One are two different text nodes now.
  • Next search can search full / part of texts - Every, One. Search query containing a part of "Every" & "One" will not be matched.

PS: Very sleepy now. Some parts of this explanation might not be clear. Ping me on @varunkumar. It can be solved by tweaking the DOM parsing.

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

3 participants