Merge pull request #5205 from eleanor-clifford/master

Fix simulateClick for <a>s inside <svg>s
This commit is contained in:
Oliver Blanthorn 2025-03-25 14:44:59 +00:00 committed by GitHub
commit f9e3e5585a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -730,7 +730,9 @@ export function simulateClick(
let usePopupBlockerWorkaround =
(target as HTMLAnchorElement).target === "_blank" ||
(target as HTMLAnchorElement).target === "_new"
const href = (target as HTMLAnchorElement).href
const href = (target instanceof SVGAElement)
? target.href.animVal
: (target as HTMLAnchorElement).href;
if (href?.startsWith("file:")) {
// file URLS cannot be opend with browser.tabs.create
// see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create#url