A regression occurs when previously working software behavior breaks after a change. Browser regressions can come from bugs or non-backward-compatible API changes, making them a risk for reusable JavaScript. section 14.2.4 section 14.2
Handle foreseeable changes, then stay ready for surprises:
- Use feature detection when an API transition is predictable; test across browsers and monitor new releases for changes you could not anticipate. section 14.2.4
- When a regression appears, address it quickly; for less popular browsers, avoid exceptions that prevent the rest of the code from running. section 14.2.4 section 14.2
Listing 14.1. Anticipating an upcoming API change
function bindEvent(element, type, handle) {
if (element.addEventListener) {
element.addEventListener(type, handle, false); #A
}
else if (element.attachEvent) {
element.attachEvent("on" + type, handle); #B
}
}
The event-binding example detects addEventListener and falls back to attachEvent when needed. section 14.2.4




