Event listener objects are no longer accepted as values of on* properties on XMLHttpRequest, FileReader, WebSocket, and EventSource objects

Published: | Categories: DOM

Description

With this change, handlers in the form of an object with a handleEvent property, e.g. xhr.onreadystatechange = { handleEvent: function() { ... } }, don’t work anymore on XMLHttpRequest, WebSocket, FileReader and EventSource objects, just like the already didn’t work on the element, document, and window objects. In Firefox (Gecko), such code will be treated as equivalent to xhr.onreadystatechange = null, thus it won’t be executed while no error causes. This is a step to comply with standards and improve interoperability; it will be the same behaviour as Internet Explorer and Opera. WebKit browsers like Google Chrome still accept such forms.

Note that xhr.onreadystatechange = function() { ... } continues to work, though using addEventListener instead is generally recommended.

References