mirror of https://github.com/jiahaog/Nativefier
Fix context menu actions broken on <a> elements containing nested markup (#263)
Merge branch 'ronjouch-patch-1' into development
This commit is contained in:
commit
2892e09db0
|
@ -16,7 +16,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
window.addEventListener('contextmenu', event => {
|
window.addEventListener('contextmenu', event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const targetElement = event.srcElement;
|
let targetElement = event.srcElement;
|
||||||
|
|
||||||
|
// the clicked element is the deepest in the DOM, and may not be the <a> bearing the href
|
||||||
|
// for example, <a href="..."><span>Google</span></a>
|
||||||
|
while (!targetElement.href && targetElement.parentElement) {
|
||||||
|
targetElement = targetElement.parentElement;
|
||||||
|
}
|
||||||
const targetHref = targetElement.href;
|
const targetHref = targetElement.href;
|
||||||
|
|
||||||
if (!targetHref) {
|
if (!targetHref) {
|
||||||
|
|
Loading…
Reference in New Issue