javascript-tutorial / javascript-tutorial/en.javascript.info
Incorrect usage of nextSibling and previousSibling
Nessuno ha ancora preso questa issue.
- Lingua principale
- HTML
- Stelle
- 25.5k
- Fork
- 4k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I encountered an error when learning about DOM navigation, in the Walking the DOM, under the Siblings and the parent using nextSibling and previousSibling. These properties return the next and previous node, which is the text node.
// parent of <body> is <html>
alert(document.body.parentNode === document.documentElement); // true
// after <head> goes <body>
alert(document.head.nextSibling); // Might not be HTMLBodyElement due to text nodes
// before <body> goes <head>
alert(document.body.previousSibling); // Might not be HTMLHeadElement due to text nodes
If you look at the alert displayed. The nextSibling and previousSibling may not return the expected HTMLBodyElement and HTMLHeadElement due to the presence of a text node.
Please consider updating, or correcting the examples.
Thank you!
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla pagina “Walking the DOM” all’URL della documentazione collegata, nello specifico dalla sezione “Siblings and the parent” e dai relativi esempi di nextSibling e previousSibling. Verifica che gli esempi tengano correttamente conto dei nodi di testo e aggiorna il testo o il codice in modo che i risultati attesi siano chiari. Il lavoro è completo quando gli esempi non implicano più che queste proprietà restituiscano sempre HTMLBodyElement o HTMLHeadElement.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 50/100