Tuesday, November 08, 2005

Safari and DOM 2 HTML

Does Safari support a HTML element hierarchy/interface, similar to Firefox's support of the DOM 2 HTML interface? It does not appear to be so. Or if it does, it doesn't expose it to scripting. True or false? Google is silent on the matter.

Links and pointers welcome.

Okay, some clarification: there's DOM 2 Core, which is the node/element interface we know and love, which allows us to express a document as a hierarchy of objects. On top of this is DOM 2 HTML which goes a step further by defining specific kinds of node/element classes to represent HTML elements. A DIV is an HTMLDivElement, an IMG is an HTMLImageElement, etc.

Each of these element node are descendants of the Mother Of All HTML Subclasses, HTMLElement.

I'm trying to determine if Safari supports DOM 2 HTML. So far, all signs point to no. In Safari, a DIV is a DIV and an IMG is an IMG. I can't really discern if the HTML elements are subclasses of some super-duper element — my guess is if there is one, it's not exposed to scripting as it is in Mozilla/Firefox. I'd love to be proven wrong.

UPDATE: according to this table, Safari 2.0.1 was 99% compliant with the DOM 2 HTML spec. So it's there. Is it scriptable? I'll have to upgrade and let you know.