Skip to content

Commit ebc46fd

Browse files
authored
Merge pull request #403 from brentguf/node-propertie
Node properties chapter
2 parents 8bb4e5b + 93f9ea2 commit ebc46fd

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

2-ui/1-document/05-basic-dom-node-properties/2-lastchild-nodetype-inline/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 5
44

55
# What's in the nodeType?
66

7-
What the script shows?
7+
What does the script show?
88

99
```html
1010
<html>

2-ui/1-document/05-basic-dom-node-properties/3-tag-in-comment/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 3
44

55
# Tag in comment
66

7-
What this code shows?
7+
What does this code show?
88

99
```html
1010
<script>

2-ui/1-document/05-basic-dom-node-properties/4-where-document-in-hierarchy/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ importance: 4
44

55
# Where's the "document" in the hierarchy?
66

7-
Which class the `document` belongs to?
7+
Which class does the `document` belong to?
88

99
What's its place in the DOM hierarchy?
1010

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Try it on `document.body`.
7676
```
7777
7878
````smart header="IDL in the spec"
79-
In the specification classes are described using not JavaScript, but a special [Interface description language](https://en.wikipedia.org/wiki/Interface_description_language) (IDL), that is usually easy to understand.
79+
In the specification, classes are described not using JavaScript, but a special [Interface description language](https://en.wikipedia.org/wiki/Interface_description_language) (IDL), that is usually easy to understand.
8080
8181
In IDL all properties are prepended with their types. For instance, `DOMString`, `boolean` and so on.
8282
@@ -163,19 +163,19 @@ Sure, the difference is reflected in their names, but is indeed a bit subtle.
163163
- The `tagName` property exists only for `Element` nodes.
164164
- The `nodeName` is defined for any `Node`:
165165
- for elements it means the same as `tagName`.
166-
- for other node types (text, comment etc) it has a string with the node type.
166+
- for other node types (text, comment, etc.) it has a string with the node type.
167167
168168
In other words, `tagName` is only supported by element nodes (as it originates from `Element` class), while `nodeName` can say something about other node types.
169169
170-
For instance let's compare `tagName` and `nodeName` for the `document` and a comment node:
170+
For instance, let's compare `tagName` and `nodeName` for the `document` and a comment node:
171171
172172
173173
```html run
174174
<body><!-- comment -->
175175
176176
<script>
177177
// for comment
178-
alert( document.body.firstChild.tagName ); // undefined (not element)
178+
alert( document.body.firstChild.tagName ); // undefined (no element)
179179
alert( document.body.firstChild.nodeName ); // #comment
180180
181181
// for document
@@ -218,7 +218,7 @@ The example shows the contents of `document.body` and then replaces it completel
218218
</body>
219219
```
220220
221-
We can try to insert an invalid HTML, the browser will fix our errors:
221+
We can try to insert invalid HTML, the browser will fix our errors:
222222
223223
```html run
224224
<body>
@@ -461,35 +461,35 @@ Most standard HTML attributes have the corresponding DOM property, and we can ac
461461
462462
If we want to know the full list of supported properties for a given class, we can find them in the specification. For instance, HTMLInputElement is documented at <https://html.spec.whatwg.org/#htmlinputelement>.
463463
464-
Or if we'd like to get them fast or interested in the concrete browser -- we can always output the element using `console.dir(elem)` and read the properties. Or explore "DOM properties" in Elements tab of the browser developer tools.
464+
Or if we'd like to get them fast or are interested in a concrete browser specification -- we can always output the element using `console.dir(elem)` and read the properties. Or explore "DOM properties" in the Elements tab of the browser developer tools.
465465
466466
## Summary
467467
468-
Each DOM node belongs to a certain class. The classes form a hierarchy. The full set of properties and methods comes as the result of inheritance.
468+
Each DOM node belongs to a certain class. The classes form a hierarchy. The full set of properties and methods come as the result of inheritance.
469469
470470
Main DOM node properties are:
471471
472472
`nodeType`
473-
: Node type. We can get it from the DOM object class, but often we need just to see if it is a text or element node. The `nodeType` property is good for that. It has numeric values, most important are: `1` -- for elements,`3` -- for text nodes. Read-only.
473+
: We can get `nodeType` from the DOM object class, but often we need just to see if it is a text or element node. The `nodeType` property is good for that. It has numeric values, most important are: `1` -- for elements,`3` -- for text nodes. Read-only.
474474
475475
`nodeName/tagName`
476-
: For elements, tag name (uppercased unless XML-mode). For non-element nodes `nodeName` describes what is it. Read-only.
476+
: For elements, tag name (uppercased unless XML-mode). For non-element nodes `nodeName` describes what it is. Read-only.
477477
478478
`innerHTML`
479-
: The HTML content of the element. Can modify.
479+
: The HTML content of the element. Can be modified.
480480
481481
`outerHTML`
482482
: The full HTML of the element. A write operation into `elem.outerHTML` does not touch `elem` itself. Instead it gets replaced with the new HTML in the outer context.
483483
484484
`nodeValue/data`
485-
: The content of a non-element node (text, comment). These two are almost the same, usually we use `data`. Can modify.
485+
: The content of a non-element node (text, comment). These two are almost the same, usually we use `data`. Can be modified.
486486
487487
`textContent`
488488
: The text inside the element, basically HTML minus all `<tags>`. Writing into it puts the text inside the element, with all special characters and tags treated exactly as text. Can safely insert user-generated text and protect from unwanted HTML insertions.
489489
490490
`hidden`
491491
: When set to `true`, does the same as CSS `display:none`.
492492
493-
DOM nodes also have other properties depending on their class. For instance, `<input>` elements (`HTMLInputElement`) support `value`, `type`, while `<a>` elements (`HTMLAnchorElement`) support `href` etc. Most standard HTML attributes have the corresponding DOM property.
493+
DOM nodes also have other properties depending on their class. For instance, `<input>` elements (`HTMLInputElement`) support `value`, `type`, while `<a>` elements (`HTMLAnchorElement`) support `href` etc. Most standard HTML attributes have a corresponding DOM property.
494494
495495
But HTML attributes and DOM properties are not always the same, as we'll see in the next chapter.

0 commit comments

Comments
 (0)