padolsey/findAndReplaceDOMText

Empty values in optional capture groups are rendered as undefined

ardcore opened this issue · 5 comments

When using replace with optional capture groups findAndReplaceDOMText seems to replace empty capture group values with undefined in HTML (instead of empty string). Example:

findAndReplaceDOMText(context, {
  find: /(This)(\s+)?(document),
  replace: "$1$2$3",
});

ran against Thisdocument (in HTML) will result in Thisundefineddocument

Hmm, am having a hard time reproducing: https://jsfiddle.net/fdqcsy9p/

Could you post the specific code that breaks if possible? Or create a small failing test case / fiddle?

https://jsfiddle.net/ef5z8j0g/ (same code, just fixed errors in your fiddle coming from my lousy paste :))

Should be fixed in v0.4.6.

(Thanks for reporting this! And lemme know if you find any other weird bugs.)

Thanks for the quick turnaround!