What does it mean to be compliant with the DOM specification?
Answer:
A DOM-compliant document model is one that responds to all the DOM API calls with the results documented in a specific Level of the DOM Recommendation. You are not required to implement the optional modules (XML, HTML, Stylesheet, CSS, Traversal, Ranges, Events or the specific event sets) in order to claim compliance, but if your DOM does not completely implement these it should respond "false" to the relevant hasFeature queries. For example, a DOM which implements just the Level 1 APIs plus the importNode method would be compliant only with Level 1, since it does not have complete support for Level 2.
In many situations, it is possible and desirable to add features to a DOM without breaking compliance. The simplest and safest way to do so is to define a new set of APIs which the objects in your customized DOM could support, so the behavior of the standard DOM API can be left unchanged. The HTML DOM is a good example of this approach; it defined a set of custom subclasses of standard DOM objects, each of which continues to respect the core DOM behaviors but also supports additional behaviors.
Some developers are starting to reuse portions of the DOM API without promising 100% DOM compliance. For example, some people have written DOM subsets (read-only DOMs, for example), or have used portions of the DOM API to build other kinds of node trees, or even mixed their own custom nodetypes with those defined by the DOM. If designed and written well, these solutions may allow _limited_ interchange of code with standard DOMs -- for example, all reasonable programs that work on a read-only DOM should run just as well on a "real" DOM, though the reverse is obviously not true. However, since the DOM's greatest value is that it promotes interoperability, such changes to the DOM's behavior should be avoided if at all possible, and will not be recognized as fully compliant implementations of the DOM.
No comments:
Post a Comment