Skip to content

Commit 924a6fb

Browse files
committed
Children: childNodes, firstChild, lastChild translated
1 parent bf8688b commit 924a6fb

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

2-ui/1-document/03-dom-navigation/article.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,69 +63,69 @@ Portanto, no exemplo abaixo, o primeiro `alert` apresentará ` null`:
6363
No DOM, o valor `null` significa "não existe" ou "nenhum nó".
6464
```
6565
66-
## Children: childNodes, firstChild, lastChild
66+
## Filhos: childNodes, firstChild, lastChild
6767
68-
There are two terms that we'll use from now on:
68+
Existem dois termos que usaremos a partir de agora:
6969
70-
- **Child nodes (or children)** -- elements that are direct children. In other words, they are nested exactly in the given one. For instance, `<head>` and `<body>` are children of `<html>` element.
71-
- **Descendants** -- all elements that are nested in the given one, including children, their children and so on.
70+
- **Nós filhos** -- elementos que são filhos diretos. Em outras palavras, eles estão exatamente aninhados no elemento pai. Por exemplo, `<head>` e `<body>` são filhos do elemento `<html>`.
71+
- **Descendentes** -- todos os elementos aninhados em um determinado elemento, incluindo filhos, netos, bisnetos e assim por diante.
7272
73-
For instance, here `<body>` has children `<div>` and `<ul>` (and few blank text nodes):
73+
Por exemplo, aqui `<body>` tem `<div>` e `<ul>` como filhos (e alguns nós de texto em branco):
7474
7575
```html run
7676
<html>
7777
<body>
78-
<div>Begin</div>
78+
<div>Começo</div>
7979
8080
<ul>
8181
<li>
82-
<b>Information</b>
82+
<b>Informação</b>
8383
</li>
8484
</ul>
8585
</body>
8686
</html>
8787
```
8888
89-
...And if we ask for all descendants of `<body>`, then we get direct children `<div>`, `<ul>` and also more nested elements like `<li>` (being a child of `<ul>`) and `<b>` (being a child of `<li>`) -- the entire subtree.
89+
...E se pedirmos todos os descendentes de `<body>`, obteremos os filhos diretos `<div>`, `<ul>` e também mais elementos aninhados como `<li>` (sendo filho de `<ul>`) e `<b>` (sendo filho de `<li>`) -- a subárvore toda.
9090
91-
**The `childNodes` collection provides access to all child nodes, including text nodes.**
91+
**A coleção `childNodes` fornece acesso a todos os nós filhos, incluindo nós de textos.**
9292
93-
The example below shows children of `document.body`:
93+
O exemplo abaixo mostra os filhos de `document.body`:
9494
9595
```html run
9696
<html>
9797
<body>
98-
<div>Begin</div>
98+
<div>Início</div>
9999
100100
<ul>
101-
<li>Information</li>
101+
<li>Informação</li>
102102
</ul>
103103
104-
<div>End</div>
104+
<div>Fim</div>
105105
106106
<script>
107107
*!*
108108
for (let i = 0; i < document.body.childNodes.length; i++) {
109-
alert( document.body.childNodes[i] ); // Text, DIV, Text, UL, ..., SCRIPT
109+
alert( document.body.childNodes[i] ); // text, div, text, ul, ..., SCRIPT
110110
}
111111
*/!*
112112
</script>
113-
...more stuff...
113+
...mais coisas...
114114
</body>
115115
</html>
116116
```
117117
118-
Please note an interesting detail here. If we run the example above, the last element shown is `<script>`. In fact, the document has more stuff below, but at the moment of the script execution the browser did not read it yet, so the script doesn't see it.
118+
Observe um detalhe interessante aqui. Se executarmos o exemplo acima, o último elemento mostrado é `<script>`. De fato, o documento tem mais informações abaixo, mas no momento da execução do script o navegador ainda não leu os elementos posteriores, portanto o script não os vê.
119119
120-
**Properties `firstChild` and `lastChild` give fast access to the first and last children.**
120+
**As propriedades `firstChild` e `lastChild` fornecem acesso rápido ao primeiro e ao último filho.**
121121
122-
They are just shorthands. If there exist child nodes, then the following is always true:
122+
São apenas abreviações. Se houver nós filhos, o seguinte sempre será verdadeiro:
123123
```js
124124
elem.childNodes[0] === elem.firstChild
125125
elem.childNodes[elem.childNodes.length - 1] === elem.lastChild
126126
```
127127
128-
There's also a special function `elem.hasChildNodes()` to check whether there are any child nodes.
128+
A função `elem.hasChildNodes()` verifica se há algum nó filho.
129129
130130
### DOM collections
131131

0 commit comments

Comments
 (0)