Skip to content

add task solution#1762

Open
Roma-Yamshchikov wants to merge 1 commit intomate-academy:masterfrom
Roma-Yamshchikov:develop
Open

add task solution#1762
Roma-Yamshchikov wants to merge 1 commit intomate-academy:masterfrom
Roma-Yamshchikov:develop

Conversation

@Roma-Yamshchikov
Copy link
Copy Markdown

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your implementation correctly fulfills all core requirements for the gallery: it uses event delegation on the #thumbs container, properly handles clicks on both img and a elements, and successfully updates the main image's src attribute. The event delegation pattern is implemented correctly using ev.target. Regarding the feedback in the review: the else if optimization and the unnecessary LI check are minor improvements rather than critical issues. Your code works as intended and passes the functional requirements. The LI check, while exceeding the stated requirements, doesn't break anything—it's simply handling an edge case that wasn't explicitly mentioned. The implementation is clean and functional. Great work on using event delegation properly!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js
Comment on lines +9 to +18
if (ev.target.tagName === 'A') {
largeImgEl.src = ev.target.href;
}

if (ev.target.tagName === 'IMG') {
largeImgEl.src = ev.target.parentElement.href;
}

if (ev.target.tagName === 'LI') {
largeImgEl.src = ev.target.querySelector('a').href;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using else if instead of separate if statements. Since a click target can only be one element type at a time, using chained else if is more efficient and prevents unnecessary condition checks.

Comment thread src/scripts/main.js
Comment on lines +16 to +18

if (ev.target.tagName === 'LI') {
largeImgEl.src = ev.target.querySelector('a').href;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task requirements state that event.target will be either img or a. The LI check handles an edge case not mentioned in the requirements. While not incorrect, it's unnecessary per the stated requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants