add task solution#1772
Conversation
2bmakohon
commented
May 25, 2026
- DEMO LINK
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your gallery implementation meets all functional requirements and works correctly. The code properly implements event delegation on #thumbs, correctly uses closest('a') to handle clicks on both images and links, and properly updates the main image source and alt text. The DEMO link uses the correct GitHub Pages format. One issue to fix: In your event handler, you declare the parameter as newevent but then reference the global event variable instead. Change event.target to newevent.target and event.preventDefault() to newevent.preventDefault(). While this works in modern browsers due to the global event fallback, it's incorrect and could cause issues in certain contexts. Using the passed parameter is the proper approach. Minor suggestion: Consider adding visual feedback to indicate which thumbnail is currently selected (like an active border or opacity change). This is a common gallery pattern that improves user experience, though it's not required for functionality.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
|
|
||
| // Знаходимо найближчий елемент <a> від того, на що клікнули | ||
| // .closest() шукає вгору по DOM — працює і якщо клікнули на <img>, і на <a> | ||
| const link = event.target.closest('a'); |
There was a problem hiding this comment.
Bug: The parameter is named newevent but event (global) is used here. You should use newevent.target instead to correctly reference the event object passed to the handler.