Findings on change listener in react

I ran into a strange issue testing a react 16 page with zombie. I was using zombie to fire a change event on a checkbox. Totally legit. But it was not calling the event listener. Knowing react uses a synthetic event system I began a long voyage into debugging this. What I found was a little strange and can be tied to this single comment.

Function shouldUseClickEvent(elem) {
// Use the `click` event to detect changes to checkbox and radio inputs.
// This approach works across all browsers, whereas `change` does not fire
// until `blur` in IE8.

So react swallows browser change events for checkboxes and relies on the fact that in order to achieve the change, a click must happen.

It listens to the click, decides its a checkbox, attaches its own change event, finds event listeners registered to onChange and goes on about its business.


But why is react making exceptions for ie8!????

Leave a Reply

Your email address will not be published. Required fields are marked *