File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -368,20 +368,19 @@ function cloneDOMTree(root) {
368368
369369``` js copy
370370/**
371- * @param {HTMLElement | null} tree
372- * @return {number}
371+ * Counts all child elements in a DOM tree.
372+ *
373+ * @param {HTMLElement | null} root - The root element from which to start counting.
374+ * @return {number} - The total number of child elements.
373375 */
374376function countElements (root ) {
375377 if (! root) return 0 ;
376378
377- let count = 1 ; // Count this element
379+ let count = 1 ;
378380
379- if (root .hasChildNodes ()) {
380- for (let child of root .children ) {
381- count += countElements (child);
382- }
381+ for (let child of root .children ) {
382+ count += countElements (child);
383383 }
384-
385384 return count;
386385}
387386```
You can’t perform that action at this time.
0 commit comments