Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Custom elements#495

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
joaquinelio merged 15 commits intojavascript-tutorial:masterfromjoaquinelio:cu
Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
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
View file
Open in desktop
Original file line numberDiff line numberDiff 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.
Por favor ten en cuenta:
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.
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.
View file
Open in desktop
Original file line numberDiff line numberDiff 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); //importante para hacer el elemento disponible al recolector de basura
}

}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
<!doctype html>
<!--don't modify this -->
<!--No modificar esto -->
<script src="time-formatted.js"></script>

<!--your code here: -->
<!--tu código aquí: -->
<script src="live-timer.js"></script>

<live-timer id="elem"></live-timer>
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
class LiveTimer extends HTMLElement {

/*your code here */
/*tu código aquí */

}

Expand Down
14 changes: 7 additions & 7 deletions8-web-components/2-custom-elements/1-live-timer/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@

#Live timer element
#Elemento reloj dinámico

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

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>).
Crea el elemento`<live-timer>`para mostrar la hora actual:
1.Internamente debe usar `<time-formatted>`, no duplicar su funcionalidad.
2.Aactualiza (¡tic!) cada segundo.
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>).

Usage:
Uso:

```html
<live-timer id="elem"></live-timer>
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp