Make mouseover/mouseout work with anchors that nest

This commit is contained in:
Maurice Parker 2020-04-20 12:14:43 -05:00
parent e459fe92b0
commit b7a37e2a25
1 changed files with 6 additions and 4 deletions

View File

@ -1,13 +1,15 @@
// Add the mouse listeners for the above functions
function linkHover() {
window.onmouseover = function(event) {
if (event.target.matches('a')) {
window.webkit.messageHandlers.mouseDidEnter.postMessage(event.target.href);
var closestAnchor = event.target.closest('a')
if (closestAnchor) {
window.webkit.messageHandlers.mouseDidEnter.postMessage(closestAnchor.href);
}
}
window.onmouseout = function(event) {
if (event.target.matches('a')) {
window.webkit.messageHandlers.mouseDidExit.postMessage(event.target.href);
var closestAnchor = event.target.closest('a')
if (closestAnchor) {
window.webkit.messageHandlers.mouseDidExit.postMessage(closestAnchor.href);
}
}
}