padolsey / findAndReplaceDOMText

:mag: Find and replace DOM text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Document prepMatch option

brettz9 opened this issue · comments

I could submit a PR for this (including within your JSDoc comments) if you like but I tend to find people like to do their own wording anyways.

And a few nits while I'm at it unless you'd like a PR (I've already made these updates in a JSLinted version if you want that):

  • toString, and isArray can be removed as they are not in use (though if you did use the latter, you might rely on Array.isArray).
  • escapeRegExp doesn't need to include / (only when you manually use one in a literal does it need to be escaped). And if you want this function as a general purpose function (e.g., including when used to escape just a part of a regular expression), it should also escape - and ,, but in your case it is not needed.

Also, your comment:

Searches for all matches that comply with the instance's 'match' option

should say:

Searches for all matches that comply with the instance's 'find' option

And as far as your comment:

         * Gets aggregate text of a node without resorting
         * to broken innerText/textContent

...do you just mean that old IE does not support textContent? If so, maybe you could try checking for textContent and only execute the function if not present (or if filterElements is in use).

Hi, sorry for the delay. I'd definitely love a PR for the wording stuff, and for removing unused functions. In regard to textContent/innerText, it always seemed precarious so I opted for walking the DOM and collecting text.

So as far as textContent, you wouldn't want to default to it when available? I think this was just an issue of IE not supporting the property previously... Also, btw, I noticed that the third argument matchIndex for getPortionReplacementNode at https://github.com/padolsey/findAndReplaceDOMText/blob/master/src/findAndReplaceDOMText.js#L370 never gets supplied; haven't examined the code carefully enough to know what you want to do with that.

Also, do you not want the JSLint?