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

Empty values in optional capture groups are rendered as undefined #70

Closed
ardcore opened this issue Dec 5, 2017 · 5 comments
Closed

Comments

@ardcore
Copy link

ardcore commented Dec 5, 2017

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
Copy link
Owner

padolsey commented Dec 5, 2017

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
Copy link
Author

ardcore commented Dec 5, 2017

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

padolsey added a commit that referenced this issue Dec 5, 2017
@padolsey
Copy link
Owner

padolsey commented Dec 5, 2017

Should be fixed in v0.4.6.

@padolsey
Copy link
Owner

padolsey commented Dec 5, 2017

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

@padolsey padolsey closed this as completed Dec 5, 2017
@ardcore
Copy link
Author

ardcore commented Dec 5, 2017

Thanks for the quick turnaround!

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

2 participants