diff --git a/src/js/contentscript.js b/src/js/contentscript.js index a78624b61..01ed23f47 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1429,11 +1429,10 @@ vAPI.bootstrap = (function() { // https://github.com/chrisaljoudi/uBlock/issues/1143 // Find a link under the mouse, to try to avoid confusing new tabs // as nuisance popups. - let elem = ev.target; - while ( elem !== null && elem.localName !== 'a' ) { - elem = elem.parentElement; - } - if ( elem === null ) { return; } + // https://github.com/uBlockOrigin/uBlock-issues/issues/777 + // Mind that href may not be a string. + const elem = ev.target.closest('a[href]'); + if ( elem === null || typeof elem.href !== 'string' ) { return; } vAPI.messaging.send('contentscript', { what: 'maybeGoodPopup', url: elem.href || '',