Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Traduction des 80% restants de la page 'Custom Elements', + exercice & solution #572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 8-web-components/2-custom-elements/1-live-timer/solution.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Please note:
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.
2. We can access current date as `elem.date` property. All class methods and properties are naturally element methods and properties.
Veuillez noter:
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LiveTimer extends HTMLElement {
}

disconnectedCallback() {
clearInterval(this.timer); // important to let the element be garbage-collected
clearInterval(this.timer); // important pour permettre à l'élément d'être supprimé de la mémoire
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class LiveTimer extends HTMLElement {

/* your code here */
/* Votre code ici */

}

Expand Down
14 changes: 7 additions & 7 deletions 8-web-components/2-custom-elements/1-live-timer/task.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

# Live timer element

We already have `<time-formatted>` element to show a nicely formatted time.
Nous avons déjà un élément `<time-formatted>` pour afficher l'heure proprement.

Create `<live-timer>` element to show the current time:
1. It should use `<time-formatted>` internally, not duplicate its functionality.
2. Ticks (updates) every second.
3. For every tick, a custom event named `tick` should be generated, with the current date in `event.detail` (see chapter <info:dispatch-events>).
Créez l'élément `<live-timer>` pour afficher l'heure actuelle:
1. Il doit réutiliser `<time-formatted>` en interne, pas dupliquer ses fonctionnalités.
2. Tick (mise à jour) toutes les secondes.
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>).

Usage:
Utilisation:

```html
<live-timer id="elem"></live-timer>
Expand All @@ -18,6 +18,6 @@ Usage:
</script>
```

Demo:
Démo:

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