Skip to content

Commit 4918bdd

Browse files
authored
Merge pull request #394 from brentguf/modifying-the-dom
Modifying the dom
2 parents be007e7 + cf7b5e2 commit 4918bdd

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

2-ui/1-document/07-modifying-document/5-why-aaa/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ The browser has to fix it automatically. But there may be no text inside the `<t
44

55
Now it's obvious that when we remove the table, it remains.
66

7-
The question can be easily answered by exploring DOM using the browser tools. They show `"aaa"` before the `<table>`.
7+
The question can be easily answered by exploring the DOM using the browser tools. It shows `"aaa"` before the `<table>`.
88

99
The HTML standard specifies in detail how to process bad HTML, and such behavior of the browser is correct.

2-ui/1-document/07-modifying-document/5-why-aaa/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 1
22

33
---
44

5-
# Why "aaa" remains?
5+
# Why does "aaa" remain?
66

7-
Run the example. Why `table.remove()` does not delete the text `"aaa"`?
7+
Run the example. Why does `table.remove()` not delete the text `"aaa"`?
88

99
```html height=100 run
1010
<table id="table">

2-ui/1-document/07-modifying-document/article.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Here's how it will look:
3030
*/!*
3131
```
3232

33-
That was an HTML example. Now let's create the same `div` with JavaScript (assuming that the styles are still in the HTML or an external CSS).
33+
That was an HTML example. Now let's create the same `div` with JavaScript (assuming that the styles are still in the HTML or an external CSS file).
3434

3535
## Creating an element
3636

@@ -61,7 +61,7 @@ div.className = "alert alert-success";
6161
div.innerHTML = "<strong>Hi there!</strong> You've read an important message.";
6262
```
6363

64-
After that, we have a ready DOM element. Right now it's in the variable, but can not be seen, because not inserted into the page yet.
64+
After that, we have a ready DOM element. Right now it's in the variable, but can not be seen, because it's not been inserted into the page yet.
6565

6666
## Insertion methods
6767

@@ -135,9 +135,8 @@ Here's a brief list of methods to insert a node into a parent element (`parentEl
135135
*/!*
136136
</script>
137137
```
138-
139-
To insert as the first element, we can do like this:
140-
138+
To insert `newLi` as the first element, we can do it like this:
139+
141140
```js
142141
list.insertBefore(newLi, list.firstChild);
143142
```
@@ -204,7 +203,7 @@ before
204203
after
205204
```
206205

207-
These methods can insert multiple list of nodes and text pieces in a single call.
206+
These methods can insert multiple lists of nodes and text pieces in a single call.
208207

209208
For instance, here a string and an element are inserted:
210209

@@ -303,7 +302,7 @@ So here's an alternative variant of showing a message:
303302

304303
How to insert one more similar message?
305304

306-
We could do a function and put the code there. But the alternative way would be to *clone* the existing `div` and modify the text inside it (if needed).
305+
We could make a function and put the code there. But the alternative way would be to *clone* the existing `div` and modify the text inside it (if needed).
307306

308307
Sometimes when we have a big element, that may be faster and simpler.
309308

@@ -338,7 +337,7 @@ An example of copying the message:
338337

339338
## Removal methods
340339

341-
To remove nodes, there are following methods:
340+
To remove nodes, there are the following methods:
342341

343342

344343
`parentElem.removeChild(node)`
@@ -412,7 +411,7 @@ The call to `document.write(html)` writes the `html` into page "right here and n
412411

413412
The method comes from times when there were no DOM, no standards... Really old times. It still lives, because there are scripts using it.
414413

415-
In modern scripts we can rarely see it, because of the important limitation.
414+
In modern scripts we can rarely see it, because of the following important limitation:
416415

417416
**The call to `document.write` only works while the page is loading.**
418417

@@ -480,4 +479,4 @@ Insertion and removal of nodes:
480479
- To append HTML to the page before it has finished loading:
481480
- `document.write(html)`
482481

483-
After the page is loaded such call erases the document. Mostly seen in old scripts.
482+
After the page is loaded such a call erases the document. Mostly seen in old scripts.

0 commit comments

Comments
 (0)