Skip to content

Commit 650e788

Browse files
committedOct 14, 2019
elks -> elk
1 parent 5fe6977 commit 650e788

15 files changed

+18
-14
lines changed
 

‎2-ui/1-document/02-dom-nodes/article.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ Let's start with the following simple document:
3232
<!DOCTYPE HTML>
3333
<html>
3434
<head>
35-
<title>About elks</title>
35+
<title>About elk</title>
3636
</head>
3737
<body>
38-
The truth about elks.
38+
The truth about elk.
3939
</body>
4040
</html>
4141
```
@@ -45,7 +45,7 @@ The DOM represents HTML as a tree structure of tags. Here's how it looks:
4545
<div class="domtree"></div>
4646

4747
<script>
48-
let node1 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n "},{"name":"TITLE","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"About elks"}]},{"name":"#text","nodeType":3,"content":"\n "}]},{"name":"#text","nodeType":3,"content":"\n "},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n The truth about elks."}]}]}
48+
let node1 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n "},{"name":"TITLE","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"About elk"}]},{"name":"#text","nodeType":3,"content":"\n "}]},{"name":"#text","nodeType":3,"content":"\n "},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n The truth about elk."}]}]}
4949

5050
drawHtmlTree(node1, 'div.domtree', 690, 320);
5151
</script>
@@ -60,7 +60,7 @@ Tags are *element nodes* (or just elements) and form the tree structure: `<html>
6060

6161
The text inside elements forms *text nodes*, labelled as `#text`. A text node contains only a string. It may not have children and is always a leaf of the tree.
6262

63-
For instance, the `<title>` tag has the text `"About elks"`.
63+
For instance, the `<title>` tag has the text `"About elk"`.
6464

6565
Please note the special characters in text nodes:
6666

@@ -79,13 +79,13 @@ Here are no space-only text nodes:
7979

8080
```html no-beautify
8181
<!DOCTYPE HTML>
82-
<html><head><title>About elks</title></head><body>The truth about elks.</body></html>
82+
<html><head><title>About elk</title></head><body>The truth about elk.</body></html>
8383
```
8484

8585
<div class="domtree"></div>
8686

8787
<script>
88-
let node2 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[{"name":"TITLE","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"About elks"}]}]},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"The truth about elks."}]}]}
88+
let node2 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[{"name":"TITLE","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"About elk"}]}]},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"The truth about elk."}]}]}
8989

9090
drawHtmlTree(node2, 'div.domtree', 690, 210);
9191
</script>
@@ -167,7 +167,7 @@ For example, comments:
167167
<!DOCTYPE HTML>
168168
<html>
169169
<body>
170-
The truth about elks.
170+
The truth about elk.
171171
<ol>
172172
<li>An elk is a smart</li>
173173
*!*
@@ -182,7 +182,7 @@ For example, comments:
182182
<div class="domtree"></div>
183183
184184
<script>
185-
let node6 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[]},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n The truth about elks.\n "},{"name":"OL","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n "},{"name":"LI","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"An elk is a smart"}]},{"name":"#text","nodeType":3,"content":"\n "},{"name":"#comment","nodeType":8,"content":"comment"},{"name":"#text","nodeType":3,"content":"\n "},{"name":"LI","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"...and cunning animal!"}]},{"name":"#text","nodeType":3,"content":"\n "}]},{"name":"#text","nodeType":3,"content":"\n \n"}]}]};
185+
let node6 = {"name":"HTML","nodeType":1,"children":[{"name":"HEAD","nodeType":1,"children":[]},{"name":"BODY","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n The truth about elk.\n "},{"name":"OL","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"\n "},{"name":"LI","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"An elk is a smart"}]},{"name":"#text","nodeType":3,"content":"\n "},{"name":"#comment","nodeType":8,"content":"comment"},{"name":"#text","nodeType":3,"content":"\n "},{"name":"LI","nodeType":1,"children":[{"name":"#text","nodeType":3,"content":"...and cunning animal!"}]},{"name":"#text","nodeType":3,"content":"\n "}]},{"name":"#text","nodeType":3,"content":"\n \n"}]}]};
186186
187187
drawHtmlTree(node6, 'div.domtree', 690, 500);
188188
</script>
@@ -210,11 +210,11 @@ To see the DOM structure in real-time, try [Live DOM Viewer](http://software.hix
210210
211211
Another way to explore the DOM is to use the browser developer tools. Actually, that's what we use when developing.
212212
213-
To do so, open the web page [elks.html](elks.html), turn on the browser developer tools and switch to the Elements tab.
213+
To do so, open the web page [elk.html](elk.html), turn on the browser developer tools and switch to the Elements tab.
214214
215215
It should look like this:
216216
217-
![](elks.png)
217+
![](elk.svg)
218218
219219
You can see the DOM, click on elements, see their details and so on.
220220
@@ -224,7 +224,7 @@ Clicking the <span class="devtools" style="background-position:-328px -124px"></
224224
225225
Another way to do it would be just right-clicking on a webpage and selecting "Inspect" in the context menu.
226226
227-
![](inspect.png)
227+
![](inspect.svg)
228228
229229
At the right part of the tools there are the following subtabs:
230230
- **Styles** -- we can see CSS applied to the current element rule by rule, including built-in rules (gray). Almost everything can be edited in-place, including the dimensions/margins/paddings of the box below.
@@ -247,15 +247,15 @@ Now the last selected element is available as `$0`, the previously selected is `
247247
248248
We can run commands on them. For instance, `$0.style.background = 'red'` makes the selected list item red, like this:
249249
250-
![](domconsole0.png)
250+
![](domconsole0.svg)
251251
252252
That's how to get a node from Elements in Console.
253253
254254
There's also a road back. If there's a variable referencing a DOM node, then we can use the command `inspect(node)` in Console to see it in the Elements pane.
255255
256256
Or we can just output the DOM node in the console and explore "in-place", like `document.body` below:
257257
258-
![](domconsole1.png)
258+
![](domconsole1.svg)
259259
260260
That's for debugging purposes of course. From the next chapter on we'll access and modify DOM using JavaScript.
261261
-92.8 KB
Binary file not shown.

‎2-ui/1-document/02-dom-nodes/domconsole0.svg

Lines changed: 1 addition & 0 deletions
Loading
-164 KB
Binary file not shown.
-70.7 KB
Binary file not shown.

‎2-ui/1-document/02-dom-nodes/domconsole1.svg

Lines changed: 1 addition & 0 deletions
Loading
-138 KB
Binary file not shown.

‎2-ui/1-document/02-dom-nodes/elks.html renamed to ‎2-ui/1-document/02-dom-nodes/elk.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE HTML>
22
<html>
33
<body>
4-
The truth about elks.
4+
The truth about elk.
55
<ol>
66
<li>An elk is a smart</li>
77
<!-- comment -->

‎2-ui/1-document/02-dom-nodes/elk.svg

Lines changed: 1 addition & 0 deletions
Loading

‎2-ui/1-document/02-dom-nodes/elks.png

-73.2 KB
Binary file not shown.
-130 KB
Binary file not shown.
-110 KB
Binary file not shown.

‎2-ui/1-document/02-dom-nodes/inspect.svg

Lines changed: 1 addition & 0 deletions
Loading
-194 KB
Binary file not shown.

‎figures.sketch

819 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.