Empty values in optional capture groups are rendered as undefined
ardcore opened this issue · 5 comments
ardcore commented
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
padolsey commented
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?
ardcore commented
https://jsfiddle.net/ef5z8j0g/ (same code, just fixed errors in your fiddle coming from my lousy paste :))
padolsey commented
(Thanks for reporting this! And lemme know if you find any other weird bugs.)
ardcore commented
Thanks for the quick turnaround!