assaf/zombie — pull request #566 by nlacasse (2013-08-26 23:42:23+00:00)
Title: Fix xhr onreadystatechange firing multiple times with state 4.

I noticed that XHRs were firing with state 4 multiple times. This doesn't affect jQuery, but it does cause problems with [superagent](https://github.com/visionmedia/superagent) and anybody coding with XHRs manually.

The root of the issue was that _stateChanged was getting called with the correct states, but the @onreadystatechange listener was being queued to run later, and when it finally does run, the state has been changed.

I cleaned up some of the listener logic, wrapped the final _stateChange in an ``enqueue``, and added a test for this scenario.