Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: DOM / JavaScript
eventsdomhovercorrectness
Use mouseenter/mouseleave instead of mouseover for hover behavior
mouseover/mouseout bubble and fire for descendant elements; mouseenter/mouseleave fire once for the element itself, which is what hover logic usually wants as the DOM grows.
PR: hegnar-bellsheep-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejs
| 1 | el.addEventListener('mouseover', onHover); // fires for every descendant too |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejs
| 1 | el.addEventListener('mouseenter', onHover); |
| 2 | el.addEventListener('mouseleave', onLeave); |
Explanation (EN)
Objašnjenje (HR)