14DOM Extensions

Even though the Document Object Model is a fairly well-defined API, it is also frequently augmented with both standards-based and proprietary extensions to provide additional functionality. Prior to 2008, almost all of the DOM extensions found in browsers were proprietary. After that point, the W3C went to work to codify some of the proprietary extensions that had become de facto standards into formal specifications.

The first level of the DOM focuses on defining the underlying structure of HTML documents. DOM Levels 2 and 3 build on this structure to introduce more interactivity and support for more advanced features.

There are also three types of observer APIs that allow you to define listeners that will fire upon various changes happening in the browser. These observer APIs are defined in different specifications, but they share a common interface:

  • Mutation Observers—Detect changes to a full or partial DOM tree
  • Intersection Observers—Detect if elements are overlapping and by how much
  • Resize Observers—Detect if an element’s dimensions change

STYLES

Styles are defined in HTML in three ways: including an external style sheet ...

Get Professional JavaScript for Web Developers, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.