liveBook · Manning

Browser bug

As explained in Secrets of the JavaScript Ninja, Second Edition

An error in a browser implementation that causes behavior to differ from what is expected.

A browser bug is an implementation error that makes behavior differ from what is expected. For reusable JavaScript, bugs and browser differences can undermine features across the browsers you support. Prioritize the browsers your audience uses, and ensure code degrades gracefully in less popular ones. section 14.2 section 14.2.1

A practical approach:

  • Test common and fringe use cases across the supported browsers. section 14.2.1
  • Avoid relying on a bug remaining: a browser update may fix it and break a workaround built around its presence. section 14.2.2
  • Balance compatibility work against your audience, development resources, and schedule. section 14.2

The root element’s scroll position

The described scrollTop and scrollLeft inconsistency illustrates why workarounds need care: IE 11 and Firefox follow the stated specification for the root html element, while Safari, Chrome, and Opera require using body for the same effect. Developers have used browser-name detection to choose between them, but a later bug fix can make such a workaround break. section 14.2.2 section 14.2.1

How Secrets of the JavaScript Ninja, Second Edition covers it

How deep it goes
Explains test coverage and workaround risks, then illustrates a DOM scrolling inconsistency; specific remediation strategies are deferred.
Examples
Uses scrollTop and scrollLeft on the root html and body elements to illustrate differing browser behavior.
What you can do after
Apply comprehensive tests across supported browsers and make workarounds resistant to future bug fixes.
How it connects
Connects browser bugs with cross-browser testing, graceful degradation, and reusable JavaScript.

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.