Javascript and W3C DOM
posted on 2006-03-11I’m currently writing the haXe interfaces for Javascript DOM Api. What a mess ! There is the W3C DOM, which is a recommended standard, with several versions, not completely implemented on different browsers, then each browser comes with its own extensions, sometimes compatible accross browsers, sometimes incompatible.
It is then not easy to comeup with a single interface. What I’m doing for haXe is the following :
- have the standard interface supporting the things supported by both IE6 and Firefox 1.0.x
- have several compilation flags to disable some fields and ensure more strict compatibility
- the
ie5
flag will ensure ie5 compatibility by disabling ie6-specific fields - the
w3c
flag will disable fields that are not w3c compatible
Conditional compilation is really a great help there. In the future when interfaces improve I will add the latest FireFox 1.5 APIs that will be turned ON with ff15
or another flag.
Other problem is inherent dynamicity of some fields, that can be of several types (Integer or String, with different formats). Having more strictly typed and sound API will be something interesting, but difficult to do. If I could get a hold on the guy responsible for all of this, I would have a few words to say to him
Hopefully haXe will greatly help developers to go through this jungle.