nit: Checking for direct property access is faster (doesn't really bother me enough that you have to change it though):

```
if (this.onerror) {
or
if (this.onerror !== undefined) {
```