Conversation
devmentor-pl
left a comment
There was a problem hiding this comment.
Neil,
Zadania są ok 👍
Zostawiłem parę drobnych uwag :)
| if (elCommentsItem) { | ||
| const dataInfoElements = elCommentsItem.querySelectorAll("[data-info]"); | ||
| console.log(`There are ${dataInfoElements.length} emelents.`); | ||
| } |
| const dataUrlList = document.querySelectorAll("a"); | ||
| if (dataUrlList) { |
There was a problem hiding this comment.
Jeśli wyszukujesz wiele elementów i żaden nie został odnaleziony to jest zwracana pusta tablica. Pusta tablica jest obiektem więc jest prawdą. Dlatego waki warunke nie ma sensu bo będzie zawsze prawdziwy. Można go pominać lub poprawić na coś takiego: if (dataUrlList.length > 0)
| } | ||
| button.innerText = buttonSettings.text; | ||
|
|
||
| parentSectionBtn.appendChild(button); |
| ancherTag.href = menuItems[i].url; | ||
| ancherTag.innerText = menuItems[i].text; | ||
| unorderdList.appendChild(listItem); | ||
| } |
| // 2. | ||
| const childArr = [...curr.parentElement.children]; | ||
| childArr.forEach((element) => { | ||
| if (element) { |
There was a problem hiding this comment.
Wyszukujemy elementy więc one nigdy nie będą "fałszywe", dlatego warunek nie jest potrzeny.
Dodałbym go jednak z innego powodu. CHciałbym dodać klasę "sibling" do rodzeństwa, a nie samego siebie - trzeba curr wykluczyć.
| }; | ||
|
|
||
| const sectionArticles = curr.parentElement.parentElement; | ||
| const newArticle = createElement(articleData.article); |
There was a problem hiding this comment.
Można też użyć cloneNode(true) - myślę, że wygodniejsze :)
No description provided.