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

Loosing onclick functionality after parse #73

Closed
jasan-s opened this issue Oct 1, 2018 · 4 comments
Closed

Loosing onclick functionality after parse #73

jasan-s opened this issue Oct 1, 2018 · 4 comments
Labels
question Further information is requested

Comments

@jasan-s
Copy link

jasan-s commented Oct 1, 2018

see https://jsfiddle.net/kvgz36eh/.

notice that the onclick methods are lost post parsing , thus on click the hidden input field value is never updated.

@remarkablemark
Copy link
Owner

Thanks for opening the issue @jasan-s

The onclick not being set on the React element is actually expected behavior. (A similar issue was brought up in #53.)

Because there's an XSS security risk when evaling the onclick string, the property is not translated in the HTMLDOMPropertyConfig map.

The best solution is to use the replace option. See updated fiddle.

@remarkablemark remarkablemark added the question Further information is requested label Oct 2, 2018
@jasan-s
Copy link
Author

jasan-s commented Oct 2, 2018

@remarkablemark thanks for that, I realized the intentional removal of dirty html afterward. I solved it using the following :
const answer = document.querySelector('input[name="otpselection"]:checked').value;
although i like your solution as well.

@kasvith
Copy link

kasvith commented Feb 6, 2024

@remarkablemark i think there should be an option for bypassing this. when a trusted backend sends html code, its much needed to handle event listners automatically

@remarkablemark
Copy link
Owner

@kasvith the recommended approach is to use the replace option. If you have any questions, feel free to open a new discussion or issue.

Repository owner locked and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants