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.

4 Comments:

At 4:38 PM, Blogger scottandrew said...

I'm asking if anyone knows if Safari supports the same HTML DOM as Firefox, or something like it, i.e. a top-level HTMLElement class from which all other HTML element descend, etc.

 
At 9:46 AM, Blogger David said...

Hawt. Please update as you figure things out.

 
At 4:39 PM, Blogger J. Russell Smyth said...

Nothing in the DOM spec requires such a top-level class, in fact, in true language agnostic fashion, the spec does not require any class heirarchy at all! All that is required is implementing the complete chain of interefaces for each element (ie the DIV element must implement HTMLDivElement, and HTMLElement) but there is no requirement of an inheritance heiararcy. You should be able to depend on the objects implementing the interface, but there is no way to depend on specific implementation details

 
At 1:13 AM, Blogger Easton said...

The information you provided here regarding firefox is eye opening, I am using firefox for years but don't have any idea about this.

-Easton
Best Loan Deals

 

Post a Comment

<< Home