Skip to content

Commit e3aff35

Browse files
authored
Merge pull request #443 from gabifs/translate/custom-elements
Custom elements
2 parents 218098a + 21bf0ad commit e3aff35

File tree

6 files changed

+202
-179
lines changed

6 files changed

+202
-179
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
Observe:
12

2-
Please note:
3-
1. We clear `setInterval` timer when the element is removed from the document. That's important, otherwise it continues ticking even if not needed any more. And the browser can't clear the memory from this element and referenced by it.
4-
2. We can access current date as `elem.date` property. All class methods and properties are naturally element methods and properties.
3+
1. Limpamos o temporizador `setInterval` quando o elemento é removido do documento. Isso é importante, caso contrário ele continua atualizando mesmo que não seja mais necessário. E o navegador não consegue limpar a memória deste elemento e referenciados por ele.
4+
2. Podemos acessar a data atual como propriedade `elem.date`. Todos os métodos e propriedades da classe são naturalmente métodos e propriedades do elemento.

8-web-components/2-custom-elements/1-live-timer/solution.view/live-timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class LiveTimer extends HTMLElement {
2424
}
2525

2626
disconnectedCallback() {
27-
clearInterval(this.timer); // important to let the element be garbage-collected
27+
clearInterval(this.timer); // importante para deixar o elemento ser coletado como lixo
2828
}
2929

3030
}

8-web-components/2-custom-elements/1-live-timer/source.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!doctype html>
2-
<!-- don't modify this -->
2+
<!-- não modifique isso -->
33
<script src="time-formatted.js"></script>
44

5-
<!-- your code here: -->
5+
<!-- seu código aqui: -->
66
<script src="live-timer.js"></script>
77

88
<live-timer id="elem"></live-timer>

8-web-components/2-custom-elements/1-live-timer/source.view/live-timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class LiveTimer extends HTMLElement {
22

3-
/* your code here */
3+
/* Seu código aqui */
44

55
}
66

8-web-components/2-custom-elements/1-live-timer/task.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
# Elemento temporizador ao vivo
12

2-
# Live timer element
3+
Já temos o elemento `<time-formatted>` para mostrar um tempo bem formatado.
34

4-
We already have `<time-formatted>` element to show a nicely formatted time.
5+
Crie o elemento `<live-timer>` para mostrar o tempo atual:
56

6-
Create `<live-timer>` element to show the current time:
7-
1. It should use `<time-formatted>` internally, not duplicate its functionality.
8-
2. Ticks (updates) every second.
9-
3. For every tick, a custom event named `tick` should be generated, with the current date in `event.detail` (see chapter <info:dispatch-events>).
7+
1. Ele deve usar `<time-formatted>` internamente, não duplicar sua funcionalidade.
8+
2. Atualiza a cada segundo.
9+
3. Para cada atualização, um evento customizado chamado `tick` deve ser gerado, com a data atual em `event.detail` (veja o capítulo <info:dispatch-events>).
1010

11-
Usage:
11+
Uso:
1212

1313
```html
1414
<live-timer id="elem"></live-timer>
1515

1616
<script>
17-
elem.addEventListener('tick', event => console.log(event.detail));
17+
elem.addEventListener("tick", (event) => console.log(event.detail));
1818
</script>
1919
```
2020

0 commit comments

Comments
 (0)