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

capability to convert attached event listeners #97

Closed
JMA12 opened this issue Mar 26, 2019 · 2 comments
Closed

capability to convert attached event listeners #97

JMA12 opened this issue Mar 26, 2019 · 2 comments
Labels
question Further information is requested

Comments

@JMA12
Copy link

JMA12 commented Mar 26, 2019

Expected Behavior

Created html strings with attached event listeners. The attached listeners will be preserved after conversion

Actual Behavior

attached listeners are not processed properly

Steps to Reproduce

* create an element which is a string
* For instance, "<span onClick={e => {console.log("test...")}}>TEST</span>"

abc

Reproducible Demo

Environment

  • Version:
  • Platform:
  • Browser:
@remarkablemark
Copy link
Owner

This is expected behavior.

html-react-parser will parse the event listeners from the HTML markup as a string. Thus, in order to call the event listener, you will need to eval it. If you do that, just be wary of XSS.

See #73.

@remarkablemark remarkablemark added the question Further information is requested label Mar 27, 2019
@JMA12
Copy link
Author

JMA12 commented Mar 27, 2019

Yes, I see.
As I read through #73, I found that using the replace method is much better.
Thanks @remarkablemark .

@JMA12 JMA12 closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants