Loosing onclick functionality after parse
jasan-s opened this issue · comments
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.
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 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.
@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