diff --git a/src/js/_enqueues/lib/embed-template.js b/src/js/_enqueues/lib/embed-template.js index ae58e4e967d7a..82b7c6c4bda89 100644 --- a/src/js/_enqueues/lib/embed-template.js +++ b/src/js/_enqueues/lib/embed-template.js @@ -156,13 +156,12 @@ * Detect clicks to external (_top) links. */ function linkClickHandler( e ) { - var target = e.target, - href; - if ( target.hasAttribute( 'href' ) ) { - href = target.getAttribute( 'href' ); - } else { - href = target.parentElement.getAttribute( 'href' ); - } + /* + * The href property resolves to an absolute URL, which the parent window requires. + * Elements whose href is not a string, such as SVG anchors, are skipped. + */ + var link = e.target.closest( '[href]' ), + href = 'string' === typeof link?.href ? link.href : null; // Only catch clicks from the primary mouse button, without any modifiers. if ( event.altKey || event.ctrlKey || event.metaKey || event.shiftKey ) {