Skip to content

Commit 8d9a24a

Browse files
authored
Merge pull request #495 from joaquinelio/cu
Custom elements
2 parents bfb6ef5 + 919de36 commit 8d9a24a

File tree

6 files changed

+115
-115
lines changed

6 files changed

+115
-115
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

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.
2+
Por favor ten en cuenta:
3+
1. Borramos el temporizador `setInterval` cuando el elemento es quitado del documento. Esto es importante, de otro modo continuará ejecutando aunque no se lo necesite más, y el navegador no puede liberar la memoria asignada a este elemento.
4+
2. Podemos acceder a la fecha actual con la propiedad `elem.date`. Todos los métodos y propiedades de clase son naturalmente métodos y propiedades del 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 hacer el elemento disponible al recolector de basura
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+
<!-- No modificar esto -->
33
<script src="time-formatted.js"></script>
44

5-
<!-- your code here: -->
5+
<!-- tu código aquí: -->
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+
/* tu código aquí */
44

55
}
66

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

2-
# Live timer element
2+
# Elemento reloj dinámico
33

4-
We already have `<time-formatted>` element to show a nicely formatted time.
4+
Ya tenemos un elemento `<time-formatted>` para mostrar la hora agradablemente formateada.
55

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>).
6+
Crea el elemento `<live-timer>` para mostrar la hora actual:
7+
1. Internamente debe usar `<time-formatted>`, no duplicar su funcionalidad.
8+
2. Aactualiza (¡tic!) cada segundo.
9+
3. Por cada tic, se debe generar un evento personalizado llamado `tick` con la fecha actual en `event.detail` (ver artículo <info:dispatch-events>).
1010

11-
Usage:
11+
Uso:
1212

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

0 commit comments

Comments
 (0)