Skip to content

Commit ed4a212

Browse files
committed
closes #3035
1 parent 25952f0 commit ed4a212

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

2-ui/1-document/05-basic-dom-node-properties/article.md

+28-7
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,39 @@ Here's the picture, explanations to follow:
1818

1919
The classes are:
2020

21-
- [EventTarget](https://dom.spec.whatwg.org/#eventtarget) -- is the root "abstract" class. Objects of that class are never created. It serves as a base, so that all DOM nodes support so-called "events", we'll study them later.
22-
- [Node](http://dom.spec.whatwg.org/#interface-node) -- is also an "abstract" class, serving as a base for DOM nodes. It provides the core tree functionality: `parentNode`, `nextSibling`, `childNodes` and so on (they are getters). Objects of `Node` class are never created. But there are concrete node classes that inherit from it, namely: `Text` for text nodes, `Element` for element nodes and more exotic ones like `Comment` for comment nodes.
23-
- [Element](http://dom.spec.whatwg.org/#interface-element) -- is a base class for DOM elements. It provides element-level navigation like `nextElementSibling`, `children` and searching methods like `getElementsByTagName`, `querySelector`. A browser supports not only HTML, but also XML and SVG. The `Element` class serves as a base for more specific classes: `SVGElement`, `XMLElement` and `HTMLElement`.
24-
- [HTMLElement](https://html.spec.whatwg.org/multipage/dom.html#htmlelement) -- is finally the basic class for all HTML elements. It is inherited by concrete HTML elements:
21+
- [EventTarget](https://dom.spec.whatwg.org/#eventtarget) -- is the root "abstract" class for everything.
22+
23+
Objects of that class are never created. It serves as a base, so that all DOM nodes support so-called "events", we'll study them later.
24+
25+
- [Node](https://dom.spec.whatwg.org/#interface-node) -- is also an "abstract" class, serving as a base for DOM nodes.
26+
27+
It provides the core tree functionality: `parentNode`, `nextSibling`, `childNodes` and so on (they are getters). Objects of `Node` class are never created. But there are other classes that inherit from it (and so inherit the `Node` functionality).
28+
29+
- [Document](https://dom.spec.whatwg.org/#interface-document), for historical reasons often inherited by `HTMLDocument` (though the latest spec doesn't dictate it) -- is a document as a whole.
30+
31+
The `document` global object belongs exactly to this class. It servers as an entry point to the DOM.
32+
33+
- [CharacterData](https://dom.spec.whatwg.org/#interface-characterdata) -- an "abstract" class, inherited by:
34+
- [Text](https://dom.spec.whatwg.org/#interface-text) -- the class corresponding to a text inside elements, e.g. `Hello` in `<p>Hello</p>`.
35+
- [Comment](https://dom.spec.whatwg.org/#interface-comment) -- the class for comments. They are not shown, but each comment becomes a member of DOM.
36+
37+
- [Element](https://dom.spec.whatwg.org/#interface-element) -- is the base class for DOM elements.
38+
39+
It provides element-level navigation like `nextElementSibling`, `children` and searching methods like `getElementsByTagName`, `querySelector`.
40+
41+
A browser supports not only HTML, but also XML and SVG. So the `Element` class serves as a base for more specific classes: `SVGElement`, `XMLElement` (we don't need them here) and `HTMLElement`.
42+
43+
- Finally, [HTMLElement](https://html.spec.whatwg.org/multipage/dom.html#htmlelement) is the basic class for all HTML elements. We'll work with it most of the time.
44+
45+
It is inherited by concrete HTML elements:
2546
- [HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) -- the class for `<input>` elements,
2647
- [HTMLBodyElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlbodyelement) -- the class for `<body>` elements,
2748
- [HTMLAnchorElement](https://html.spec.whatwg.org/multipage/semantics.html#htmlanchorelement) -- the class for `<a>` elements,
2849
- ...and so on.
2950

3051
There are many other tags with their own classes that may have specific properties and methods, while some elements, such as `<span>`, `<section>`, `<article>` do not have any specific properties, so they are instances of `HTMLElement` class.
3152

32-
So, the full set of properties and methods of a given node comes as the result of the inheritance.
53+
So, the full set of properties and methods of a given node comes as the result of the chain of inheritance.
3354

3455
For example, let's consider the DOM object for an `<input>` element. It belongs to [HTMLInputElement](https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement) class.
3556

@@ -133,10 +154,10 @@ For instance:
133154
<script>
134155
let elem = document.body;
135156
136-
// let's examine what it is?
157+
// let's examine: what type of node is in elem?
137158
alert(elem.nodeType); // 1 => element
138159
139-
// and the first child is...
160+
// and its first child is...
140161
alert(elem.firstChild.nodeType); // 3 => text
141162
142163
// for the document object, the type is 9
Loading

figures.sketch

2.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)