Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/js/_enqueues/lib/embed-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Loading