代码改变世界

Study DOM

2012-07-30 10:27  @影子@  阅读(203)  评论(0编辑  收藏  举报

DOM 层次

DOM1

包括2个部分,分别为Core和HTML。

DOM1 core提供了一系列文档结构的基本接口,同事定义了外部XML文档的接口。

HTML1 提供了比DOM1更高层的接口,使得操作文档变得更为方便,所有的属性和方法都可以直接和XML、HTML进行交互

 

DOM2

DOM2包含六个部分,分别为 Core 、Views 、Events、 Style、 Traversal、 Range 和 DOM2 HTML

Mozilla支持DOM2的大部分特性

DOM Level 1

The DOM Level 1 specification is separated into two parts: Core and HTML. Core Level 1 provides a low-level set of fundamental interfaces that can represent any structured document, as well as defining extended interfaces for representing an XML document. HTML Level 1 provides additional, higher-level interfaces that are used with the fundamental interfaces defined in Core Level 1 to provide a more convenient view of an HTML document. Interfaces introduced in DOM1 include, among others, the Document, Node, Attr, Element, and Text interfaces. All interfaces contain attributes and/or methods that can be used to interact with XML and HTML documents.

Level of support: Excellent. See our bugs in the Core and HTML specifications.
 

DOM Level 2

The DOM Level 2 specification contains six different specifications: The DOM2 Core, Views, Events, Style, Traversal and Range, and the DOM2 HTML. Most of the DOM Level 2 is supported in Mozilla.

  1. The DOM2 Core extends the functionality of the DOM1 Core. It also contains specialized interfaces dedicated to XML. Examples of methods introduced in the DOM2 Core include the famous getElementById, and many namespace-related methods.

    Level of support: Very good. See our bugs in the Core specification.

  2. The DOM2 Viewsallows programs and scripts to dynamically access and update the content of a representation of a document. The introduced interfaces are AbstractView and DocumentView.

    Level of support: Perfect.

  3. The DOM2 Events gives a generic event system to programs and scripts. It introduces the concepts of event flow, capture, bubbling, and cancellation. Famous methods here include addEventListener and handleEvent. Several interfaces make your life easier when dealing with events: EventTarget, EventListener, Event, DocumentEvent, MouseEvent, MutationEvent, etc. However, it does not include an interface for the keyboard events, which will be dealt with in later versions of the DOM.

    Level of support: Very good. See our bugs in the Events specification.

  4. The DOM2 CSS, or DOM2 Style, allows programs and scripts to dynamically access and update the content of style sheets. It has interfaces for Style Sheets, Cascading Style Sheets, CSSRule, CSSStyleDeclaration, the famous getComputedStyle (supported in Mozilla), the many many CSS2Properties, and all the media rules you can imagine.

    Level of support: Good. See our bugs in the Style specification.

  5. The DOM2 Traversal and Range allow programs and scripts to dynamically traverse and identify a range of content in a document. The DOM2 Traversal provides interfaces like NodeIterator and TreeWalkerto easily traverse the content of a document. The DOM2 Range allows the creation, insertion, modification, and deletion of a range of content in a Document, DocumentFragment, or Attr. It can be characterized as selecting all of the content between a pair of boundary-points.

    Level of support: Good for Range; for Traversal, the TreeWalker is supported, and NodeIterator support was implemented in Firefox 3.5.

  6. The DOM2 HTMLallows programs and scripts to dynamically access and update the content and structure of HTML documents. It extends the interfaces defined in the DOM1 HTML, using the DOM2 Core possibilities. It introduces the contentDocument property, a useful way to access the document contained in a frame.

    Level of support: Good. See our bugs in the HTML specification.

DOM3

定义了5个部分,分别为 Core、 Load and Save、Validation、Events、Xpath

 

  1. The DOM3 Core will extend the functionality of the DOM1 and DOM2 Core specs. New methods and properties include adoptNode() and textContent, to name a couple.

    Level of support: Only a few properties and methods are supported, like baseURI. If you want to help with the code, please see bug 159167 .

  2. The DOM3 Load and Saveallows programs and scripts to dynamically load the content of an XML document into a DOM document, and serialize a DOM document into an XML document.

    Level of support: None ( bug 155749 ). Mozilla supports non-standard DOMParser and XMLSerializer objects instead.

  3. The DOM3 Validationallows programs and scripts to dynamically update the content and the structure of documents while ensuring that the document remains valid, or to ensure that the document becomes valid.

    Level of support: None.

  4. The DOM3 Eventsis the extension of the DOM2 Events specification. This specification mainly focuses on keyboard events and how to handle them.

    Level of support: Parts.

  5. The DOM3 XPathprovides simple functionalities to access a DOM tree using XPath 1.0.

    Level of support: Parts. See XPath

    参考文献:

    https://developer.mozilla.org/en/DOM_Levels     

    https://developer.mozilla.org/en/Gecko_DOM_Reference