Skip to content

Commit e11f7fe

Browse files
feat: Translated the remaining 80% of 'Custom elements' page, + exercise, + solution
1 parent c02fa1d commit e11f7fe

File tree

5 files changed

+110
-118
lines changed

5 files changed

+110
-118
lines changed
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+
Veuillez noter:
3+
1. On nettoie le timer `setInterval` quand l'élément est supprimé du document. C'est important, car sans ça, il continuera à s'éxécuter même si il ne sert plus à rien. Et le navigateur ne pourra pas vider la mémoire associée et référencée par cet élément.
4+
2. On peut accéder à la date actuelle via la propriété `elem.date`. Toutes les méthodes et propriétés de classe sont aussi des méthodes et propriétés d'élement.

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

+1-1
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); // important pour permettre à l'élément d'être supprimé de la mémoire
2828
}
2929

3030
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class LiveTimer extends HTMLElement {
22

3-
/* your code here */
3+
/* Votre code ici */
44

55
}
66

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
# Live timer element
33

4-
We already have `<time-formatted>` element to show a nicely formatted time.
4+
Nous avons déjà un élément `<time-formatted>` pour afficher l'heure proprement.
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+
Créez l'élément `<live-timer>` pour afficher l'heure actuelle:
7+
1. Il doit réutiliser `<time-formatted>` en interne, pas dupliquer ses fonctionnalités.
8+
2. Tick (mise à jour) toutes les secondes.
9+
3. Pour chaque tick, un évènement personnalisé appelé `tick` devrait être généré, avec la date/heure actuelle accessible via `event.detail` (Voir le chapitre <info:dispatch-events>).
1010

11-
Usage:
11+
Utilisation:
1212

1313
```html
1414
<live-timer id="elem"></live-timer>
@@ -18,6 +18,6 @@ Usage:
1818
</script>
1919
```
2020

21-
Demo:
21+
Démo:
2222

2323
[iframe src="solution" height=40]

0 commit comments

Comments
 (0)