Inside IE 8′s mutable DOM prototypes

When Internet Exporer 8 was released, a much talked-about feature was mutable DOM prototypes. I dug in this morning to figure out exactly what is and is not supported. As one would expect, the support is not as full as the nice writeup would have everyone believe. Here’s a quick summary:

  • The Node type doesn’t exist, so you still can’t access Node.ELEMENT_NODE as you can in other browsers.
  • The Element type exists, but since Node doesn’t, it’s not a subtype.
  • The HTMLElement type doesn’t exist even though, technically, HTMLElement is the base type for all of the other HTML element types. For example, HTMLBodyElement inherits from HTMLElement which inherits from Element.
  • Getters and setters are supported via __defineGetter__() and __defineSetter__(). Sadly, these are only available on the DOM types and not on native JScript objects.
  • Other available types: NodeList, NamedNodeMap, Attr, Text, DOMImplementation, HTMLDocument, HTMLCollection. Each of these supports getters and setters.
  • Sadly, none of the DOM types are native JScript types, meaning the JScript engine sees all of the functions on the prototypes as objects and Array.prototype.slice() still can’t be used on NodeList or HTMLCollection objects.

I guess this is a good start from where IE was prior to this release, though still somewhat disappointing. Hopefully this feature will be more fleshed-out once they go GA.

Understanding JavaScript Promises E-book Cover

Demystify JavaScript promises with the e-book that explains not just concepts, but also real-world uses of promises.

Download the Free E-book!

The community edition of Understanding JavaScript Promises is a free download that arrives in minutes.