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

indexInMatch always negative of indexInNode #60

Closed
jeffhaessler opened this issue May 13, 2017 · 2 comments
Closed

indexInMatch always negative of indexInNode #60

jeffhaessler opened this issue May 13, 2017 · 2 comments
Assignees
Labels

Comments

@jeffhaessler
Copy link

Hi,

I've noticed that indexInMatch is just returning the negative of indexInNode. Is that the expected behavior? I'm having trouble understanding how to use this to locate the portion within the match.

https://jsfiddle.net/wou9Lxa4/4/

@padolsey
Copy link
Owner

Yep, this is a bug. At the moment indexInMatch only produces a useful number when a match has more than one portion. (When there is only one portion in a match it seems to produce a pointless number)

E.g. of multiple portions:

<div><span>In t<em>h</em>e morning and in the afternoon.</span></div>

The first "the" is split up between three different nodes, and the replace callback is called for each portion, producing an indexInMatch of 0 (t), 1 (h) and 2 (e).

The indexInMatch should definitely be zero for cases of matches with a single portion. I'll have a look into this. Thanks for spotting it!

@padolsey padolsey self-assigned this May 13, 2017
@padolsey padolsey added the bug label May 13, 2017
@padolsey
Copy link
Owner

padolsey commented Dec 5, 2017

Fix released in 0.4.6. Sorry for the ridiculous delay.

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

No branches or pull requests

2 participants