liveBook · Manning

Regression

As explained in Secrets of the JavaScript Ninja, Second Edition

A failure of previously working software behavior following a change.

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

How Secrets of the JavaScript Ninja, Second Edition covers it

How deep it goes
Defines regressions, distinguishes predictable API changes from unpredictable bugs, and recommends feature detection, testing, and release monitoring.
Examples
Uses the Internet Explorer transition from attachEvent to addEventListener to demonstrate feature detection.
What you can do after
Diagnose regressions by testing browser releases and addressing failures; anticipate known API changes with feature detection.
How it connects
Connects regressions to feature detection, browser testing, backward compatibility, and cross-browser compatibility.

Also explained in

Compare how 5 books explain regression →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Second Edition. The section links point to the parts of the book it draws on.