Dynamic HTML: The Definitive Reference, 2rd Ed.Dynamic HTML: The Definitive ReferenceSearch this book

7.4. DOM Modularization (DOM2 and DOM3)

The W3C DOM Level 2 specification is divided into six documents, but these documents define a total of 14 modules. The Core module (which is shared by all others) defines a hasFeature( ) method that belongs to the DOMImplementation object (itself a property of the root document node). This method allows a script to query the client as to whether a particular module and module version is implemented in the browser. Syntax for this method is as follows:

var isImplemented = document.implementation.hasFeature("feature", "version");

The first parameter is a string that is associated with each module (e.g., "Core", or "MouseEvents"), while the second parameter is a string of the DOM level number for the module (e.g., "2.0" or "3.0"). Each module also maintains its own definition of conformance. The hasFeature( ) method is supposed to return true only if the conformance specifications for a particular module are met.

Netscape 6 and later implements the document.implementation property (which corresponds to DOMImplementation) and the hasFeature( ) method, which as of this writing, reports that several 2.0 modules are implemented. IE 5 for the Mac implements the hasFeature( ) method, but it does not report any modules as being implemented in full. IE 6 for Windows does not implement the document.implementation property, so scripts cannot inquire into W3C DOM module status in this browser version. It will obviously take browser development reaching critical mass among installed browsers before scripts can make intelligent use of this feature query mechanism.

Table 7-3 lists the DOM modules for Level 2 and those proposed for Level 3. The feature name and available version numbers for each module appear in the table, as well. A module that indicates Version 2.0 but not 3.0 means that the module specifications have not changed for the 3.0 generation.

Table 7-3. DOM modules

Module

Feature string

Version 2.0

Version 3.0

Core

"Core"

XML

"XML"

HTML

"HTML"

 

Views

"Views"

 

Style Sheets

"StyleSheets"

 

CSS

"CSS"

 

CSS2

"CSS2"

 

Events

"Events"

User Interface Events

"UIEvents"

Mouse Events

"MouseEvents"

Text Events

"TextEvents"  

Mutation Events

"MutationEvents"

HTML Events

"HTMLEvents"

Range

"Range"

 

Traversal

"Traversal"

 

Load and Save

"LS"  

Abstract Schemas Editing

"AS-EDIT"  

XPath

"XPath"  



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.