diff --git a/2-ui/1-document/03-dom-navigation/article.md b/2-ui/1-document/03-dom-navigation/article.md index 80054f9d7..0871eafae 100644 --- a/2-ui/1-document/03-dom-navigation/article.md +++ b/2-ui/1-document/03-dom-navigation/article.md @@ -5,37 +5,37 @@ libs: --- -# Walking the DOM +# Percorrendo o DOM -The DOM allows us to do anything with elements and their contents, but first we need to reach the corresponding DOM object, get it into a variable, and then we are able to modify it. +O DOM nos permite fazer qualquer coisa com elementos e seu conteúdo, mas primeiro precisamos alcançar o objeto DOM correspondente. -All operations on the DOM start with the `document` object. From it we can access any node. +Todas as operações no DOM começam com o objeto `document`. Esse é o principal "ponto de entrada" para o DOM. A partir dele, podemos acessar qualquer nó. -Here's a picture of links that allow for travel between DOM nodes: +Aqui está uma imagem das interligações que permitem navegar entre os nós do DOM: ![](dom-links.svg) -Let's discuss them in more detail. +Vamos abordar em mais detalhes. -## On top: documentElement and body +## Na parte superior: documentElement e body -The topmost tree nodes are available directly as `document` properties: +Os nós mais acima na árvore do DOM estão disponíveis diretamente como propriedades de `document`: `` = `document.documentElement` -: The topmost document node is `document.documentElement`. That's DOM node of `` tag. +: O mais alto nó de document é `document.documentElement`. Este é o nó do elemento ``. `` = `document.body` -: Another widely used DOM node is the `` element -- `document.body`. +: Outro nó amplamente utilizado é o elemento `` -- `document.body`. `` = `document.head` -: The `` tag is available as `document.head`. +: O elemento `` está acessível como `document.head`. -````warn header="There's a catch: `document.body` can be `null`" -A script cannot access an element that doesn't exist at the moment of running. +````warn header="Há um problema: `document.body` pode ser `null`" +No momento da execução, um script não pode acessar um elemento que ainda não existe. -In particular, if a script is inside ``, then `document.body` is unavailable, because the browser did not read it yet. +Em particular, se um script estiver dentro de ``, então `document.body` estará indisponível, porquê o navegador ainda não o encontrou. -So, in the example below the first `alert` shows `null`: +Portanto, no exemplo abaixo, o primeiro `alert` apresentará ` null`: ```html run @@ -43,7 +43,7 @@ So, in the example below the first `alert` shows `null`: @@ -51,7 +51,7 @@ So, in the example below the first `alert` shows `null`: @@ -59,209 +59,209 @@ So, in the example below the first `alert` shows `null`: ``` ```` -```smart header="In the DOM world `null` means \"doesn't exist\"" -In the DOM, the `null` value means "doesn't exist" or "no such node". +```smart header="No DOM, `null` significa \"não existe\"" +No DOM, o valor `null` significa "não existe" ou "nenhum nó". ``` -## Children: childNodes, firstChild, lastChild +## Filhos: childNodes, firstChild, lastChild -There are two terms that we'll use from now on: +Existem dois termos que usaremos a partir de agora: -- **Child nodes (or children)** -- elements that are direct children. In other words, they are nested exactly in the given one. For instance, `` and `` are children of `` element. -- **Descendants** -- all elements that are nested in the given one, including children, their children and so on. +- **Nós filhos** -- elementos que são filhos diretos. Em outras palavras, eles estão exatamente aninhados no elemento pai. Por exemplo, `` e `` são filhos do elemento ``. +- **Descendentes** -- todos os elementos aninhados em um determinado elemento, incluindo filhos, netos, bisnetos e assim por diante. -For instance, here `` has children `
` and `