aggiornamento Javascript#4
aggiornamento Javascript#4capmar00 wants to merge 6 commits intoshetechitaly:mainfrom capmar00:jsUpdateBranch
Conversation
MelaHub
left a comment
There was a problem hiding this comment.
Due commenti giusto per aiutarmi a capire cos'è cambiato - per qualche motivo github ha beccato troppi changes che in realtà penso non ci siano stati
day-01/08.html
Outdated
| <hr> | ||
| <button onclick="clearCompleted()" class="btn btn-default btn-xs">Clear completed</button> | ||
| </div> | ||
| <form onsubmit="createNew(event)" class="panel-heading"> |
There was a problem hiding this comment.
può essere che segni più cambiamenti di quelli effettivi perché lo consideravo un mio file personale ed ero andata avanti a fare modifiche che poi non ho integrato nella pull request.
- ho messo il tag template nel body e ho aggiornato la funzione renderItem di conseguenza
- ho trasformato tutte le funzioni in arrow function e le ho definite come costanti
There was a problem hiding this comment.
nel weekend posso rifarlo dal file di partenza, così almeno segna solo i cambiamenti effettivi
day-01/08.html
Outdated
|
|
||
| updateList(listItems, true); | ||
| } | ||
| const loadList = () => { |
There was a problem hiding this comment.
Mi riesci a rimettere l'indentazione com'era prima? Così
- riesco a vedere meglio cos'è cambiato
- rimane indentato rispetto al tag
| listElement.innerHTML += renderItem(item); | ||
| const updateList = (items, save) => { | ||
| const listElement = document.querySelector("#task-list"); | ||
| while (listElement.firstChild) listElement.removeChild(listElement.firstChild); |
| const renderItem = (item) => { | ||
| const template = document.getElementById("item-template"); | ||
| const instance = document.importNode(template.content, true); | ||
| instance.querySelector(".list-group-item > span").innerText = item.text; |
There was a problem hiding this comment.
@capmar00 forse qui possiamo togliere allora i placeholder TEXT e COMPLETED nell'html?
| items.forEach(function(item) { | ||
| listElement.innerHTML += renderItem(item); | ||
| const updateList = (items, save) => { | ||
| const listElement = document.querySelector("#task-list"); |
There was a problem hiding this comment.
Come mai stai dichiarando i const dappertutto quando non sono const?
Mi spiego - listElement la stiamo modificando - non sarebbe più opportuno lasciarla var?
Correzione del martedì mattina - qua sarebbe opportuno usare let invece di const
rinfrescato il javascript aggiungendo const e let, arrow functions, differenziando qualche selettore e sostituendo qualche innerHTML