add task solution#1762
Conversation
Roma-Yamshchikov
commented
May 9, 2026
- DEMO LINK
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| 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; |
There was a problem hiding this comment.
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.
|
|
||
| if (ev.target.tagName === 'LI') { | ||
| largeImgEl.src = ev.target.querySelector('a').href; |
There was a problem hiding this comment.
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.